mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-05-01 23:31:03 +02:00

Add support for CMake find_package command to msgpack. The package exports the two targets msgpackc-static and msgpackc if shared is enabled. The CMake find_package command works after installation of msgpack and during build of another project which adds msgpack as sub project via add_subdirectory command. Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
34 lines
1.2 KiB
CMake
34 lines
1.2 KiB
CMake
IF (MSGPACK_BOOST)
|
|
LIST (APPEND exec_PROGRAMS
|
|
msgpack_variant_capitalize.cpp
|
|
msgpack_variant_mapbased.cpp
|
|
)
|
|
ENDIF ()
|
|
|
|
FOREACH (source_file ${exec_PROGRAMS})
|
|
GET_FILENAME_COMPONENT (source_file_we ${source_file} NAME_WE)
|
|
ADD_EXECUTABLE (
|
|
${source_file_we}
|
|
${source_file}
|
|
)
|
|
TARGET_INCLUDE_DIRECTORIES (${source_file_we}
|
|
PRIVATE
|
|
$<TARGET_PROPERTY:msgpackc,INTERFACE_INCLUDE_DIRECTORIES>
|
|
)
|
|
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 -Werror -g -O3")
|
|
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 ()
|