Is there a way to configure the cygwin cmake to fetch cygwin CUnit without having to create a
FindCunit.cmake
?
Unless CUnit comes with its own find module which CMake can find (quick web search suggests it does not) then you have to tell CMake how to find that library. You don't need to create a file as such - you could just put the contents in the calling CMakeLists.txt but some might consider it tidier to have the extra file.
if no how can I solve my path issue?
The CMake find_
functions have an additional flag you can pass in. It is one of the following: CMAKE_FIND_ROOT_PATH_BOTH
, NO_CMAKE_FIND_ROOT_PATH
ONLY_CMAKE_FIND_ROOT_PATH
.
The docs describe these in more detail, but to simplify it:
CMAKE_FIND_ROOT_PATH_BOTH
tells the function to search for the path you've given it, as well as the same path with the sysroot prefixed. i.e with a sysroot of /foo
and a search path of /bar
, it will search in /foo/bar
and /bar
.NO_CMAKE_FIND_ROOT_PATH
ignores the sysrootONLY_CMAKE_FIND_ROOT_PATH
only searches under the sysroot.By default, CMake will search in the re-rooted dirs first, and then in the non-rooted ones, however even if you don't specify that argument, there are various CMake variables which affect this behaviour. Search for CMAKE_FIND_ROOT_PATH_MODE_
here. I assume you're using a CMake toolchain file to set you up for cross-compilation - this might be setting one of these without you knowing.
To add to this, you're on Windows and the args you're passing as PATHS
will not work when not re-rooting the search directories as they're Linux ones. (/usr/include/
is not a valid Windows path)