CMake executable location

You have a couple of choices. To change the default location of executables, set CMAKE_RUNTIME_OUTPUT_DIRECTORY to the desired location. For example, if you add set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) to your Project/CMakeLists.txt before the add_subdirectory command, your executable will end up in Project/build for Unix builds or build/<config type> for Win32 builds. For further details, run: cmake … Read more

Doxygen – Could NOT find FLEX (missing: FLEX_EXECUTABLE)

It seems like apt autoremove really removed the package I just installed in the previous step. So what worked for me was: git clone https://github.com/doxygen/doxygen.git cd doxygen mkdir build cd build These are new: sudo apt-get install flex sudo apt-get install bison cmake -G “Unix Makefiles” .. make …but of course the horror wouldn’t end … Read more

How to always run command when building regardless of any dependency?

While I’m not at all pleased with this solution, posting since I stumbled on this page and didn’t see it mentioned. You can add a custom target that references a missing file, eg: if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/__header.h) message(FATAL_ERROR “File \”${CMAKE_CURRENT_BINARY_DIR}/__header.h\” found, \ this should never be created, remove!”) endif() add_custom_target( my_custom_target_that_always_runs ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/__header.h ) add_custom_command( OUTPUT … Read more

How to run ctest after building my project with cmake

This form of add_custom_command will only execute if another CMake target has a dependency on “tests.txt”. I assume that no other target has “tests.txt” as an input file, hence the custom command never runs. I think you could use the second form of add_custom_command to achieve your goal; something like: add_custom_command(TARGET MainTest POST_BUILD COMMAND ctest … Read more

Using cmake to create main and sub-projects, and be able to compile them individually

There are a few strategies which may work, some of which could be combined. STRATEGY 1: If you are using the Unix Makefiles generator with CMake, then simply invoking make from the build output dir that corresponds to the subdirectory you want to build should largely accomplish what you describe. Targets from other directories won’t … Read more

Ternary operator in CMake’s generator expressions

Note that cmake 3.8 added exactly what you want to generator expressions … $<IF:?,true-value…,false-value…> true-value… if ? is 1, false-value… if ? is 0 Example usage: target_link_libraries(MyLib PUBLIC $<IF:$<CONFIG:Debug>,cppzmq,cppzmq-static> ) Where cppzmq is shared library used in Debug build and cppzmq-static is static library used in other case e.g. Release

Detect current CMake version using CMake

There exist a few variables for that, described here: CMAKE_MAJOR_VERSION major version number for CMake, e.g. the “2” in CMake 2.4.3 CMAKE_MINOR_VERSION minor version number for CMake, e.g. the “4” in CMake 2.4.3 CMAKE_PATCH_VERSION patch version number for CMake, e.g. the “3” in CMake 2.4.3 Also, the variable CMAKE_VERSION contains the string for the version. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)