Skip to content

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
wants to merge 19 commits into from
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ compile_commands.json
*.a

# eclipse project files
.idea/
.project
.cproject
/.settings/
Expand All @@ -55,3 +56,4 @@ compile_commands.json

# temps
/version
cmake-build-*/
29 changes: 4 additions & 25 deletions example/CMakeLists.txt
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/)
3 changes: 3 additions & 0 deletions example/readFromStream/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_executable(readFromStream readFromStream.cpp)
target_include_directories(readFromStream PUBLIC ${CMAKE_SOURCE_DIR}/include)
target_link_libraries(readFromStream jsoncpp_lib)
3 changes: 3 additions & 0 deletions example/readFromString/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_executable(readFromString readFromString.cpp)
target_include_directories(readFromString PUBLIC ${CMAKE_SOURCE_DIR}/include)
target_link_libraries(readFromString jsoncpp_lib)
3 changes: 3 additions & 0 deletions example/streamWrite/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_executable(streamWrite streamWrite.cpp)
target_include_directories(streamWrite PUBLIC ${CMAKE_SOURCE_DIR}/include)
target_link_libraries(streamWrite jsoncpp_lib)
3 changes: 3 additions & 0 deletions example/stringWrite/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_executable(stringWrite stringWrite.cpp)
target_include_directories(stringWrite PUBLIC ${CMAKE_SOURCE_DIR}/include)
target_link_libraries(stringWrite jsoncpp_lib)