5
我想讓我的cmake項目自動編譯,但是當我的路徑包含空格時,我遇到了一些困難。如果環境變量有空格,find_path不起作用
這是我的命令行(Windows命令提示)
C:\Code\codetrainerplugins-build>type %CODETRAINER_PATH%\include\common\exportapi.h
#pragma once
... the file is found ...
這是我的CMakeLists.txt文件:
CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
PROJECT (CodeTrainerPlugins)
MESSAGE("$ENV{CODETRAINER_PATH}")
FIND_PATH (CODETRAINER_FRAMEWORK_PATH
NAMES include/common/ExportApi.h
PATHS
ENV CODETRAINER_PATH
)
if (CODETRAINER_FRAMEWORK_PATH)
MESSAGE(STATUS "CodeTrainer Framework found at: ${CODETRAINER_FRAMEWORK_PATH}")
else()
MESSAGE(FATAL_ERROR "CodeTrainer Framework not found")
endif()
ADD_SUBDIRECTORY(function)
ADD_SUBDIRECTORY(test)
下面是當CODETRAINER_PATH變量包含空格的輸出(參見空間路徑):
C:\Code\codetrainerplugins-build>echo %CODETRAINER_PATH%
"C:\Code Trainer"
C:\Code\codetrainerplugins-build>
C:\Code\codetrainerplugins-build>cmake ..\codetrainerplugins
-- Building for: Visual Studio 10
"C:\Code Trainer"
CMake Error at CMakeLists.txt:16 (MESSAGE):
CodeTrainer Framework not found
-- Configuring incomplete, errors occurred!
See also "C:/Code/codetrainerplugins-build/CMakeFiles/CMakeOutput.log".
C:\Code\codetrainerplugins-build>
但是當使用的路徑沒有空格時, rks ok(參見下文):
C:\Code\codetrainerplugins-build>echo %CODETRAINER_PATH%
C:\CodeTrainer
C:\Code\codetrainerplugins-build>cmake ..\codetrainerplugins
C:\CodeTrainer
-- CodeTrainer Framework found at: C:/CodeTrainer
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Code/codetrainerplugins-build
C:\Code\codetrainerplugins-build>
你有解決方案如何解決這個問題?
我對Windows使用cmake 2.8.12。
感謝, 尤利安
非常好的調查(+1)。乾杯! – INS