-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Description
jsoncpp/src/lib_json/CMakeLists.txt
Line 111 in b511d9e
| add_compile_definitions(JSON_DLL_BUILD) |
The following part for the shared library is incorrect:
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0)
add_compile_definitions(JSON_DLL_BUILD)
else()
add_definitions(-DJSON_DLL_BUILD)
endif()
What's wrong with that? Both commands add the definition globally to the compiler for the entire project. This means that if the static library is built after the shared library, the compiler will also have the definition there. Fix:
target_compile_definitions(${SHARED_LIB} PUBLIC JSON_DLL PRIVATE JSON_DLL_BUILD)
Why also JSON_DLL? Currently, JSON_DLL is not written to the configuration file during export. This means that if you want to use the shared library, you have to set the definition yourself.
However, the fix must be inserted after
jsoncpp/src/lib_json/CMakeLists.txt
Line 117 in b511d9e
| add_library(${SHARED_LIB} SHARED ${PUBLIC_HEADERS} ${JSONCPP_SOURCES}) |
and not before it. Otherwise, the target cannot be found.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels