alice
(alice)
April 7, 2022, 8:28am
1
if I let DJPEG_INCLUDE_DIRS=…\ …\libjpeg-turbo\include
the error will say can’t parse “\l” until I change \ to /
But other parameter DCMAKE_INSTALL_PREFIX or DOPENCV_EXTRA_MODULES_PATH can use the \
Why? How to know when using the / or \
cmake -G "Visual Studio 16 2019" ^
-S . ^
-DCMAKE_INSTALL_PREFIX=..\release ^
DOPENCV_EXTRA_MODULES_PATH=..\opencv_contrib\modules ^
-DJPEG_INCLUDE_DIRS=../../libjpeg-turbo/include
If \
works in some situations, it is by pure chance. CMake paths use always ‘/’.
alice
(alice)
April 7, 2022, 10:56am
3
Which is the correct ( " " or not " " )?
DJPEG_INCLUDE_DIRS=…/…/libjpeg-turbo/include
DJPEG_INCLUDE_DIRS="…/…/libjpeg-turbo/include"
cmake always use “/”, you mean windows and linux?
But windows path is D:\test
linux is /home/test
Yes. CMake is a multi-platform tool, so it uses its own format for paths.
CMake takes care to convert to native format when it interacts with the system…
alice
(alice)
April 7, 2022, 1:51pm
5
Can I make sure that both of them are correct?
DJPEG_INCLUDE_DIRS=…/…/libjpeg-turbo/include
DJPEG_INCLUDE_DIRS="…/…/libjpeg-turbo/include"
The second is wrong. When you specify arguments on the command line, you have to quote, if needed, the whole expression:
.cmake .. "-DDJPEG_INCLUDE_DIRS=…/…/libjpeg-turbo/include"
See the Quoting Simple Command Arguments section of my blog post for a more detailed discussion of the quoting behavior you’re asking about.
Get some clarity on CMake's quoting rules, as we highlight common pitfalls and offer guidelines for safer use.
Est. reading time: 10 minutes
fdk17
April 9, 2022, 9:17pm
8
“-DJPEG_INCLUDE_DIRS:PATH=…\libjpeg-turbo\include” would probably do what you want. CMake should convert relative path to an absolute path with proper slashes on a windows command line. Those other variables also get set to PATH type from what I remember.
See CMake(1) documentation on -D.
alice
(alice)
April 12, 2022, 9:43am
9
cmake always use “/”
I meet the problem.
SET PREFIX=../release
cmake --install build --config release --prefix %PREFIX%
xcopy build\xxx.lib %PREFIX%\lib
the xcopy dest will be the ../release\lib
hsattler
(Hendrik Sattler)
April 12, 2022, 12:33pm
10
xcopy build\xxx.lib %PREFIX:/=\%\lib
But that’s knowledge about how to use your shell and unrelated to cmake.
Also, instead of xcopy, properly use install() commands to the wanted result?
alice
(alice)
April 13, 2022, 2:49am
11
cmake always use “/”
xcpoy use " \ "
I try to use the “” on --prefix, it work
cmake --install build --config release --prefix ..\release