Commit 86a4baba authored by Michael Sherman's avatar Michael Sherman
Browse files

Force CMake to include C++ libraries when building a static C main program.

parent dee9f78c
...@@ -89,7 +89,9 @@ FOREACH(EX_ROOT ${C_EXAMPLES}) ...@@ -89,7 +89,9 @@ FOREACH(EX_ROOT ${C_EXAMPLES})
IF (BUILD_TESTING_STATIC) IF (BUILD_TESTING_STATIC)
# Link with static library # Link with static library
SET(EX_STATIC ${EX_ROOT}Static) SET(EX_STATIC ${EX_ROOT}Static)
ADD_EXECUTABLE(${EX_STATIC} ${EX_ROOT}.c) # We need at least one .cpp here to get CMake to include
# C++ libraries on the static link line.
ADD_EXECUTABLE(${EX_STATIC} ${EX_ROOT}.c Empty.cpp)
SET_TARGET_PROPERTIES(${EX_STATIC} SET_TARGET_PROPERTIES(${EX_STATIC}
PROPERTIES PROPERTIES
COMPILE_FLAGS "-DOPENMM_USE_STATIC_LIBRARIES" COMPILE_FLAGS "-DOPENMM_USE_STATIC_LIBRARIES"
......
// This empty C++ source file is just used to
// trick CMake into linking with C++ libraries
// when building a C main program statically.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment