From c829c73d4ec4a949e40803ffd7f49842c28df4d2 Mon Sep 17 00:00:00 2001 From: Chenguoping Date: Wed, 2 Sep 2020 11:20:03 +0800 Subject: [PATCH] fix inconsistency when build both shared/static lib --- src/jsontestrunner/CMakeLists.txt | 4 +--- src/lib_json/CMakeLists.txt | 8 ++++++-- src/test_lib_json/CMakeLists.txt | 4 +--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/jsontestrunner/CMakeLists.txt b/src/jsontestrunner/CMakeLists.txt index 1fc71ea87..d24aa6f46 100644 --- a/src/jsontestrunner/CMakeLists.txt +++ b/src/jsontestrunner/CMakeLists.txt @@ -19,10 +19,8 @@ if(BUILD_SHARED_LIBS) else() add_definitions(-DJSON_DLL) endif() - target_link_libraries(jsontestrunner_exe jsoncpp_lib) -else() - target_link_libraries(jsontestrunner_exe jsoncpp_static) endif() +target_link_libraries(jsontestrunner_exe jsoncpp_lib) set_target_properties(jsontestrunner_exe PROPERTIES OUTPUT_NAME jsontestrunner_exe) diff --git a/src/lib_json/CMakeLists.txt b/src/lib_json/CMakeLists.txt index af2647652..8cdc5e234 100644 --- a/src/lib_json/CMakeLists.txt +++ b/src/lib_json/CMakeLists.txt @@ -151,7 +151,11 @@ if(BUILD_SHARED_LIBS) endif() if(BUILD_STATIC_LIBS) - set(STATIC_LIB ${PROJECT_NAME}_static) + if (BUILD_SHARED_LIBS) + set(STATIC_LIB ${PROJECT_NAME}_static) + else() + set(STATIC_LIB ${PROJECT_NAME}_lib) + endif() add_library(${STATIC_LIB} STATIC ${PUBLIC_HEADERS} ${JSONCPP_SOURCES}) # avoid name clashes on windows as the shared import lib is alse named jsoncpp.lib @@ -160,7 +164,7 @@ if(BUILD_STATIC_LIBS) endif() set_target_properties(${STATIC_LIB} PROPERTIES - OUTPUT_NAME jsoncpp${STATIC_SUFFIX} + OUTPUT_NAME jsoncpp VERSION ${PROJECT_VERSION} ) diff --git a/src/test_lib_json/CMakeLists.txt b/src/test_lib_json/CMakeLists.txt index 1c3fce913..b803db669 100644 --- a/src/test_lib_json/CMakeLists.txt +++ b/src/test_lib_json/CMakeLists.txt @@ -15,10 +15,8 @@ if(BUILD_SHARED_LIBS) else() add_definitions( -DJSON_DLL ) endif() - target_link_libraries(jsoncpp_test jsoncpp_lib) -else() - target_link_libraries(jsoncpp_test jsoncpp_static) endif() +target_link_libraries(jsoncpp_test jsoncpp_lib) # another way to solve issue #90 #set_target_properties(jsoncpp_test PROPERTIES COMPILE_FLAGS -ffloat-store)