CMake and Static Linking

I’ve managed to solve my problem by using the following: #Dynamic/Shared Libs … #Static start set_target_properties(icarus PROPERTIES LINK_SEARCH_START_STATIC 1) set_target_properties(icarus PROPERTIES LINK_SEARCH_END_STATIC 1) set(CMAKE_FIND_LIBRARY_SUFFIXES “.a”) #Static Libs … #Set Linker flags set(CMAKE_EXE_LINKER_FLAGS “-static-libgcc -static-libstdc++”) This works without passing a -static which creates other big issues, and can essentially mix static and dynamic libraries. As long … Read more

cmake – Global linker flag setting (for all targets in directory)

Your problems are/were not related to a specific CMake version. It’s the same for all linker/compiler flag variables in CMake. Because those variables are cached variables and set with the project()/enable_language() command (details see here), you either have to prefill the cache with set(… CACHE …) before the project() command generally use the set(… CACHE … Read more