![]() Target_link_libraries( PRIVATE cmocka-static). Then the target cmocka-static will be available for # Download cmocka, and execute its cmakelists.txtĪnd then in your CMakelists.txt, simply call include(cmake/FetchCMocka.cmake). Set(PICKY_DEVELOPER OFF CACHE BOOL "CMocka: Build with picky developer flags" FORCE) Set(UNIT_TESTING OFF CACHE BOOL "CMocka: Build with unit testing" FORCE) Set(WITH_EXAMPLES OFF CACHE BOOL "CMocka: Build examples" FORCE) Set(WITH_CMOCKERY_SUPPORT OFF CACHE BOOL "CMocka: Install a cmockery header" FORCE) ![]() Then you let your users tell you which set of flags they want to use: Using presets: cmake -presetmsvc cmake -presetgcc cmake -presetclang Using toolchains: cmake -S. There are some extensive examples in the documentation. Alexander Neundorf wrote: > Hi, > CMAKECXXFLAGSRELEASE and CMAKECXXFLAGSDEBUG are appended to > CMAKECXXFLAGS if the buildtype is release or debug.> Now let's say I'd like to have the following flags: > default: -Wall -fno-rtti -O2 -g > release: -Wall -fno-rtti -O2 > debug: -Wall -fno-rtti -O0 -g > I can't set CMAKECXXFLAGS to '-Wall -fno-rtti -O2' because the -O2 will. # We want to link to cmocka-static, so we need to set this option before calling the FetchContent_MakeAvailable # We also don't care about example and tests set(WITH_STATIC_LIB ON CACHE BOOL "CMocka: Build with a static library" FORCE) With a preset, it's as simple as writing a CMakePresets.json file. # Also specify GIT_SHALLOW to avoid cloning branch we don't care about We want the lastest stable version, not the master.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |