-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Better support for modern CMake #1374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
a4ebb37
Added new rule
fb0a546
Better CMake for examples
c0cadd9
Better support to CMake
0cc72eb
Removed targets for Apple
575313c
Removed unnecessary files from library definition
952c15c
Removed problematic targets
30e4023
Better Quality Test
59f4b2c
Better Quality Test
6b0719a
Better Quality Test
398da6b
Removed global directives
cda19ed
Added documentation
3e90985
Format to lower-case
a7ba7f7
Format to lower-case
25f8762
Format to lower-case
6d1b014
Added missing rule
f54f580
Added extra properties
4c79fda
Lower-case format
c3be313
Merge remote-tracking branch 'origin/master'
bd5bc9a
Added full rules
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,6 @@ | ||
#vim: et ts =4 sts = 4 sw = 4 tw = 0 | ||
set(EXAMPLES | ||
readFromString | ||
readFromStream | ||
stringWrite | ||
streamWrite | ||
) | ||
add_definitions(-D_GLIBCXX_USE_CXX11_ABI) | ||
|
||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") | ||
add_compile_options(-Wall -Wextra) | ||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") | ||
add_definitions( | ||
-D_SCL_SECURE_NO_WARNINGS | ||
-D_CRT_SECURE_NO_WARNINGS | ||
-D_WIN32_WINNT=0x601 | ||
-D_WINSOCK_DEPRECATED_NO_WARNINGS | ||
) | ||
endif() | ||
|
||
foreach(example ${EXAMPLES}) | ||
add_executable(${example} ${example}/${example}.cpp) | ||
target_include_directories(${example} PUBLIC ${CMAKE_SOURCE_DIR}/include) | ||
target_link_libraries(${example} jsoncpp_lib) | ||
endforeach() | ||
|
||
add_custom_target(examples ALL DEPENDS ${EXAMPLES}) | ||
add_subdirectory(readFromStream/) | ||
add_subdirectory(readFromString/) | ||
add_subdirectory(streamWrite/) | ||
add_subdirectory(stringWrite/) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
add_executable(readFromStream readFromStream.cpp) | ||
target_link_libraries(readFromStream PRIVATE jsoncpp::framework) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
add_executable(readFromString readFromString.cpp) | ||
target_link_libraries(readFromString PRIVATE jsoncpp::framework) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
add_executable(streamWrite streamWrite.cpp) | ||
target_link_libraries(streamWrite PRIVATE jsoncpp::framework) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
add_executable(stringWrite stringWrite.cpp) | ||
target_link_libraries(stringWrite PRIVATE jsoncpp::framework) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,2 @@ | ||
file(GLOB INCLUDE_FILES "json/*.h") | ||
install(FILES | ||
${INCLUDE_FILES} | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/json) | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,33 @@ | ||
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0) | ||
# The new Python3 module is much more robust than the previous PythonInterp | ||
find_package(Python3 COMPONENTS Interpreter) | ||
# Set variables for backwards compatibility with cmake < 3.12.0 | ||
set(PYTHONINTERP_FOUND ${Python3_Interpreter_FOUND}) | ||
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) | ||
else() | ||
set(Python_ADDITIONAL_VERSIONS 3.8) | ||
find_package(PythonInterp 3) | ||
endif() | ||
|
||
add_executable(jsontestrunner_exe | ||
main.cpp | ||
) | ||
# The new Python3 module is much more robust than the previous PythonInterp | ||
find_package(Python3 COMPONENTS Interpreter) | ||
# Set variables for backwards compatibility with cmake < 3.12.0 | ||
set(PYTHONINTERP_FOUND ${Python3_Interpreter_FOUND}) | ||
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) | ||
|
||
if(BUILD_SHARED_LIBS) | ||
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.12.0) | ||
add_compile_definitions( JSON_DLL ) | ||
else() | ||
add_definitions(-DJSON_DLL) | ||
endif() | ||
target_link_libraries(jsontestrunner_exe jsoncpp_lib) | ||
else() | ||
target_link_libraries(jsontestrunner_exe jsoncpp_static) | ||
endif() | ||
add_executable(jsontestrunner_exe main.cpp) | ||
target_link_libraries(jsontestrunner_exe PRIVATE jsoncpp::framework) | ||
|
||
set_target_properties(jsontestrunner_exe PROPERTIES OUTPUT_NAME jsontestrunner_exe) | ||
|
||
if(PYTHONINTERP_FOUND) | ||
# Run end to end parser/writer tests | ||
set(TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../test) | ||
set(RUNJSONTESTS_PATH ${TEST_DIR}/runjsontests.py) | ||
set(RUNJSONTESTS_PATH ${JSONCPP_ROOT_DIR}/test/runjsontests.py) | ||
|
||
# Run unit tests in post-build | ||
# (default cmake workflow hides away the test result into a file, resulting in poor dev workflow?!?) | ||
add_custom_target(jsoncpp_readerwriter_tests | ||
"${PYTHON_EXECUTABLE}" -B "${RUNJSONTESTS_PATH}" $<TARGET_FILE:jsontestrunner_exe> "${TEST_DIR}/data" | ||
"${PYTHON_EXECUTABLE}" -B "${RUNJSONTESTS_PATH}" $<TARGET_FILE:jsontestrunner_exe> "${JSONCPP_ROOT_DIR}/test/data" | ||
DEPENDS jsontestrunner_exe jsoncpp_test | ||
) | ||
add_custom_target(jsoncpp_check DEPENDS jsoncpp_readerwriter_tests) | ||
|
||
## Create tests for dashboard submission, allows easy review of CI results https://my.cdash.org/index.php?project=jsoncpp | ||
add_test(NAME jsoncpp_readerwriter | ||
COMMAND "${PYTHON_EXECUTABLE}" -B "${RUNJSONTESTS_PATH}" $<TARGET_FILE:jsontestrunner_exe> "${TEST_DIR}/data" | ||
WORKING_DIRECTORY "${TEST_DIR}/data" | ||
COMMAND "${PYTHON_EXECUTABLE}" -B "${RUNJSONTESTS_PATH}" $<TARGET_FILE:jsontestrunner_exe> "${JSONCPP_ROOT_DIR}/test/data" | ||
WORKING_DIRECTORY "${JSONCPP_ROOT_DIR}/test/data" | ||
) | ||
add_test(NAME jsoncpp_readerwriter_json_checker | ||
COMMAND "${PYTHON_EXECUTABLE}" -B "${RUNJSONTESTS_PATH}" --with-json-checker $<TARGET_FILE:jsontestrunner_exe> "${TEST_DIR}/data" | ||
WORKING_DIRECTORY "${TEST_DIR}/data" | ||
COMMAND "${PYTHON_EXECUTABLE}" -B "${RUNJSONTESTS_PATH}" --with-json-checker $<TARGET_FILE:jsontestrunner_exe> "${JSONCPP_ROOT_DIR}/test/data" | ||
WORKING_DIRECTORY "${JSONCPP_ROOT_DIR}/test/data" | ||
) | ||
endif() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.