mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-05-28 15:14:11 +02:00

There are three switches to build static/shared libraries. Here is the logic. If BUILD_SHARED_LIBS is defined If BUILD_SHARED_LIBS is ON build only shared-library Else build only static-library Endif Else If MSGPACK_ENABLE_SHARED is ON (default) build shared-library Endif If MSGPACK_ENABLE_STATIC is ON (default) build static-library Endif Endif Here is common settings: If you want to build both static/shared libraries, don't set switches. If you want to build only shared-library, set BUILD_SHARED_LIBS=ON. If you want to build only static-library, set BUILD_SHARED_LIBS=OFF.
43 lines
1.2 KiB
CMake
43 lines
1.2 KiB
CMake
IF (MSGPACK_ENABLE_SHARED)
|
|
SET (MSGPACK_LIB msgpackc)
|
|
ENDIF ()
|
|
|
|
IF (MSGPACK_ENABLE_STATIC)
|
|
SET (MSGPACK_LIB msgpackc-static)
|
|
ENDIF ()
|
|
|
|
|
|
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}
|
|
${MSGPACK_LIB}
|
|
)
|
|
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 ()
|