windows - find_path doesn't work if environment variable has spaces -
I'm trying to automatically compile my cmake project, but if there's an empty space in my path, there are problems.
Here's my command line (Windows Command Prompt)
c: \ code \ codetrainerplugins-build> Type% CODETRAINER_PATH% \ include \ common \ exportapi.h #pragma Once ... the file has been found ...
Here is my CMClists.txt file:
CMAKE_MINIMUM_REQUIRED (code 2.6) project (codetrainer plugin) message ("$ ENV (CODETRAINER_PATH)" FIND_PATH (CODETRAINER_FRAMEWORK_PATH NAMES / Common / ExportApi.h PATHS ENV CODETRAINER_PATH) If (CODETRAINER_FRAMEWORK_PATH) message (STATUS "CodeTrainer Framework found: $ { CODETRAINER_FRAMEWORK_PATH} ") and () message (FATAL_ERROR" CodeTrainer Framework Not Found ") ADIF (ADD_SUBDIRECTORY) (ADD_SUBDIRECTORY) (test)
Here is the output when CODETRAIN ER_PATH Include spaces (see space on the way):
C: \ code \ codetrainerplugins- create & gt;% CODETRAINER_PATH% echo "C: \ Code Trainer" C: \ code \ codetrainerplugins- Construction & gt; C: \ code \ codetrainerplugins-create & gt; Cmake .. \ codetrainerplugins - For Building: Visual Studio 10 "C: \ Code Trainer" CMake Error on CMakeLists.txt: 16 (Message): CodeTrainer Framework Not Found - Incomplete configuration, errors occurred! See also "C: /Code/codetrainerplugins-build/CMakeFiles/CemakeOutput.log" C: \ code \ codetrainerplugins-create & gt;
But when there is no empty space in the path to use, then everything is fine (see below):
C: \ code \ Codetrainerplugins-build> Echo% CODETRAINER_PATH% C: \ CodeTrainer C: \ code \ codetrainerplugins-create & gt; Cmake .. \ codetrainerplugins C: -: C: \ CodeTrainer found in CodeTrainer Framework / Configuring CodeTrainer - Completed - Created - Creates for Build Files: C: / Code / CodeNenerPlugin-Build C: \ Code \ codetrainerplugins -build & gt;
Do you have a solution to solve this problem?
I am using cmake 2.8.12 for Windows.
Thanks, Iulian
I have to accept, I expected this to be " Just work ", though it seems that this is actually the reason for the problem in the quotation marks given in CODETRAINER_PATH
.
Either do not add quotation when defining the environment variable CODETRAINER_PATH
STRING (change "\" "" "" CODETRAINER_PATH_WITHOUT_QUOTES $ ENV {CODETRAINER_PATH} }) FIND_PATH (CODETRAINER_FRAMEWORK_PATH) includes / $ /> via the usual / ExportApi.h, or modify some of your CMake code like this {CODETRAINER_PATH_WITHOUT_QUOTES})
Comments
Post a Comment