fix inconsistency when build both shared/static lib

This commit is contained in:
Chenguoping 2020-09-02 11:20:03 +08:00
parent 5be07bdc5e
commit c829c73d4e
3 changed files with 8 additions and 8 deletions

View File

@ -19,10 +19,8 @@ if(BUILD_SHARED_LIBS)
else() else()
add_definitions(-DJSON_DLL) add_definitions(-DJSON_DLL)
endif() endif()
target_link_libraries(jsontestrunner_exe jsoncpp_lib)
else()
target_link_libraries(jsontestrunner_exe jsoncpp_static)
endif() endif()
target_link_libraries(jsontestrunner_exe jsoncpp_lib)
set_target_properties(jsontestrunner_exe PROPERTIES OUTPUT_NAME jsontestrunner_exe) set_target_properties(jsontestrunner_exe PROPERTIES OUTPUT_NAME jsontestrunner_exe)

View File

@ -151,7 +151,11 @@ if(BUILD_SHARED_LIBS)
endif() endif()
if(BUILD_STATIC_LIBS) 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}) add_library(${STATIC_LIB} STATIC ${PUBLIC_HEADERS} ${JSONCPP_SOURCES})
# avoid name clashes on windows as the shared import lib is alse named jsoncpp.lib # avoid name clashes on windows as the shared import lib is alse named jsoncpp.lib
@ -160,7 +164,7 @@ if(BUILD_STATIC_LIBS)
endif() endif()
set_target_properties(${STATIC_LIB} PROPERTIES set_target_properties(${STATIC_LIB} PROPERTIES
OUTPUT_NAME jsoncpp${STATIC_SUFFIX} OUTPUT_NAME jsoncpp
VERSION ${PROJECT_VERSION} VERSION ${PROJECT_VERSION}
) )

View File

@ -15,10 +15,8 @@ if(BUILD_SHARED_LIBS)
else() else()
add_definitions( -DJSON_DLL ) add_definitions( -DJSON_DLL )
endif() endif()
target_link_libraries(jsoncpp_test jsoncpp_lib)
else()
target_link_libraries(jsoncpp_test jsoncpp_static)
endif() endif()
target_link_libraries(jsoncpp_test jsoncpp_lib)
# another way to solve issue #90 # another way to solve issue #90
#set_target_properties(jsoncpp_test PROPERTIES COMPILE_FLAGS -ffloat-store) #set_target_properties(jsoncpp_test PROPERTIES COMPILE_FLAGS -ffloat-store)