msgpack/example/c/CMakeLists.txt
Stefan Herbrechtsmeier 6046d5c666 cmake: Remove alias from package config
The cmake target of an alias may not be an Imported Target.
Always build the msgpackc target and only build the msgpackc-static
target if both should be build to fix issue #801. Thereby the type
(shared or static) of the msgpackc target depends on the build
configuration.
2019-09-20 22:10:40 +02:00

34 lines
1.1 KiB
CMake

LIST (APPEND exec_PROGRAMS
lib_buffer_unpack.c
simple_c.c
speed_test_uint32_array.c
speed_test_uint64_array.c
user_buffer_unpack.c
)
FOREACH (source_file ${exec_PROGRAMS})
GET_FILENAME_COMPONENT (source_file_we ${source_file} NAME_WE)
ADD_EXECUTABLE (
${source_file_we}
${source_file}
)
TARGET_LINK_LIBRARIES (${source_file_we}
msgpackc
)
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wall -Wextra")
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
SET_PROPERTY (TARGET ${source_file_we} APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-mismatched-tags")
ENDIF ()
IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
IF (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
STRING(REGEX REPLACE "/W[0-4]" "/W3 /WX" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
ELSE ()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /WX")
ENDIF ()
ENDIF ()
ENDFOREACH ()