I am currently working on a project which is using cmake. The project has alsa as an optional dependency. Thus the projects CMakeLists.txt contains.
find_package(ALSA)
However I want the build to never build against alsa, even if if is on my system. (Kind of like the --without-ALSA that would have been in a configure)
I want to do this in a commandline-parameter when running cmake, not by modifying the CMakeLists.txt
Is this possible with cmake?
EDIT:
OR would it be better to have the project implement something like this:
if(WITH_ALSA)
find_package(ALSA REQUIRED)
elseif(NOT WITHOUT_ALSA)
find_package(ALSA)
endif()
EDIT2:
In the end I used the with & without option I described above (edit1). To have a little readability I defined a macro that acually does everything for me.
See the FindOptionalPackage.cmake in the FreeRDP project
First run CMake and open the generated CMakeCache.txt file. You will find something like:
ALSA_INCLUDE_DIR=/usr/include/alsa
(you basically just need to know how the variable is called). Then you should be able to call cmake with a parameter
This tells cmake, that alsa is not on your system. If this does not work, try to look at other variables containing alsa and set them to some values indicating the library could not been found. If the FindALSA.cmake script is implemented correctly (i.e. does correct caching), this should work.