Upgrade CMake to 3.1 for Hunter

This commit is contained in:
Isaac Hier 2018-03-11 09:34:45 -04:00
parent d098c0ff86
commit d8798468c6

View File

@ -46,9 +46,8 @@
cmake_minimum_required (VERSION 2.8) cmake_minimum_required (VERSION 3.1)
# required for exports? cmake_minimum_required (VERSION 2.8.6) project(jansson C)
project (jansson C)
# Options # Options
option(JANSSON_BUILD_SHARED_LIBS "Build shared libraries." OFF) option(JANSSON_BUILD_SHARED_LIBS "Build shared libraries." OFF)
@ -104,12 +103,12 @@ include (CheckTypeSize)
if (MSVC) if (MSVC)
# Turn off Microsofts "security" warnings. # Turn off Microsofts "security" warnings.
add_definitions( "/W3 /D_CRT_SECURE_NO_WARNINGS /wd4005 /wd4996 /nologo" ) add_definitions( "/W3 /D_CRT_SECURE_NO_WARNINGS /wd4005 /wd4996 /nologo" )
if (JANSSON_STATIC_CRT) if (JANSSON_STATIC_CRT)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
endif() endif()
endif() endif()
if (NOT WIN32 AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)) if (NOT WIN32 AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX))
@ -338,7 +337,7 @@ set(JANSSON_HDR_PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/utf.h ${CMAKE_CURRENT_SOURCE_DIR}/src/utf.h
${CMAKE_CURRENT_BINARY_DIR}/private_include/jansson_private_config.h) ${CMAKE_CURRENT_BINARY_DIR}/private_include/jansson_private_config.h)
set(JANSSON_HDR_PUBLIC set(JANSSON_HDR_PUBLIC
${CMAKE_CURRENT_BINARY_DIR}/include/jansson_config.h ${CMAKE_CURRENT_BINARY_DIR}/include/jansson_config.h
${CMAKE_CURRENT_SOURCE_DIR}/src/jansson.h) ${CMAKE_CURRENT_SOURCE_DIR}/src/jansson.h)
@ -347,19 +346,19 @@ source_group("Library Private Headers" FILES ${JANSSON_HDR_PRIVATE})
source_group("Library Public Headers" FILES ${JANSSON_HDR_PUBLIC}) source_group("Library Public Headers" FILES ${JANSSON_HDR_PUBLIC})
if(JANSSON_BUILD_SHARED_LIBS) if(JANSSON_BUILD_SHARED_LIBS)
add_library(jansson SHARED add_library(jansson SHARED
${JANSSON_SRC} ${JANSSON_SRC}
${JANSSON_HDR_PRIVATE} ${JANSSON_HDR_PRIVATE}
${JANSSON_HDR_PUBLIC} ${JANSSON_HDR_PUBLIC}
src/jansson.def) src/jansson.def)
set_target_properties(jansson PROPERTIES set_target_properties(jansson PROPERTIES
VERSION ${JANSSON_VERSION} VERSION ${JANSSON_VERSION}
SOVERSION ${JANSSON_SOVERSION}) SOVERSION ${JANSSON_SOVERSION})
else() else()
add_library(jansson add_library(jansson
${JANSSON_SRC} ${JANSSON_SRC}
${JANSSON_HDR_PRIVATE} ${JANSSON_HDR_PRIVATE}
${JANSSON_HDR_PUBLIC}) ${JANSSON_HDR_PUBLIC})
endif() endif()
@ -374,12 +373,12 @@ if (JANSSON_BUILD_DOCS)
find_package(Sphinx) find_package(Sphinx)
if (NOT SPHINX_FOUND) if (NOT SPHINX_FOUND)
message(WARNING "Sphinx not found. Cannot generate documentation! message(WARNING "Sphinx not found. Cannot generate documentation!
Set -DJANSSON_BUILD_DOCS=OFF to get rid of this message.") Set -DJANSSON_BUILD_DOCS=OFF to get rid of this message.")
else() else()
if (Sphinx_VERSION_STRING VERSION_LESS 1.0) if (Sphinx_VERSION_STRING VERSION_LESS 1.0)
message(WARNING "Your Sphinx version is too old! message(WARNING "Your Sphinx version is too old!
This project requires Sphinx v1.0 or above to produce This project requires Sphinx v1.0 or above to produce
proper documentation (you have v${Sphinx_VERSION_STRING}). proper documentation (you have v${Sphinx_VERSION_STRING}).
You will get output but it will have errors.") You will get output but it will have errors.")
endif() endif()
@ -432,7 +431,7 @@ if (JANSSON_BUILD_DOCS)
list(APPEND DOC_TARGETS latex) list(APPEND DOC_TARGETS latex)
endif() endif()
endif() endif()
# The doc target will build all documentation targets. # The doc target will build all documentation targets.
add_custom_target(doc) add_custom_target(doc)
@ -576,7 +575,7 @@ if (NOT JANSSON_WITHOUT_TESTS)
# Enable using "make check" just like the autotools project. # Enable using "make check" just like the autotools project.
# By default cmake creates a target "make test" # By default cmake creates a target "make test"
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}
DEPENDS json_process ${api_tests}) DEPENDS json_process ${api_tests})
endif () endif ()
@ -622,33 +621,33 @@ export(TARGETS jansson
export(PACKAGE jansson) export(PACKAGE jansson)
# Generate the config file for the build-tree. # Generate the config file for the build-tree.
set(JANSSON__INCLUDE_DIRS set(JANSSON__INCLUDE_DIRS
"${PROJECT_SOURCE_DIR}/include" "${PROJECT_SOURCE_DIR}/include"
"${PROJECT_BINARY_DIR}/include") "${PROJECT_BINARY_DIR}/include")
set(JANSSON_INCLUDE_DIRS ${JANSSON__INCLUDE_DIRS} CACHE PATH "Jansson include directories") set(JANSSON_INCLUDE_DIRS ${JANSSON__INCLUDE_DIRS} CACHE PATH "Jansson include directories")
configure_file(${PROJECT_SOURCE_DIR}/cmake/JanssonConfig.cmake.in configure_file(${PROJECT_SOURCE_DIR}/cmake/JanssonConfig.cmake.in
${PROJECT_BINARY_DIR}/JanssonConfig.cmake ${PROJECT_BINARY_DIR}/JanssonConfig.cmake
@ONLY) @ONLY)
# Generate the config file for the installation tree. # Generate the config file for the installation tree.
file(RELATIVE_PATH file(RELATIVE_PATH
REL_INCLUDE_DIR REL_INCLUDE_DIR
"${JANSSON_INSTALL_CMAKE_DIR}" "${JANSSON_INSTALL_CMAKE_DIR}"
"${JANSSON_INSTALL_INCLUDE_DIR}") # Calculate the relative directory from the Cmake dir. "${JANSSON_INSTALL_INCLUDE_DIR}") # Calculate the relative directory from the Cmake dir.
# Note the EVENT_CMAKE_DIR is defined in JanssonConfig.cmake.in, # Note the EVENT_CMAKE_DIR is defined in JanssonConfig.cmake.in,
# we escape it here so it's evaluated when it is included instead # we escape it here so it's evaluated when it is included instead
# so that the include dirs are given relative to where the # so that the include dirs are given relative to where the
# config file is located. # config file is located.
set(JANSSON__INCLUDE_DIRS set(JANSSON__INCLUDE_DIRS
"\${JANSSON_CMAKE_DIR}/${REL_INCLUDE_DIR}") "\${JANSSON_CMAKE_DIR}/${REL_INCLUDE_DIR}")
configure_file(${PROJECT_SOURCE_DIR}/cmake/JanssonConfig.cmake.in configure_file(${PROJECT_SOURCE_DIR}/cmake/JanssonConfig.cmake.in
${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/JanssonConfig.cmake ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/JanssonConfig.cmake
@ONLY) @ONLY)
# Generate version info for both build-tree and install-tree. # Generate version info for both build-tree and install-tree.
configure_file(${PROJECT_SOURCE_DIR}/cmake/JanssonConfigVersion.cmake.in configure_file(${PROJECT_SOURCE_DIR}/cmake/JanssonConfigVersion.cmake.in
${PROJECT_BINARY_DIR}/JanssonConfigVersion.cmake ${PROJECT_BINARY_DIR}/JanssonConfigVersion.cmake
@ONLY) @ONLY)
# Define the public headers. # Define the public headers.
@ -668,7 +667,7 @@ install(TARGETS jansson
PUBLIC_HEADER DESTINATION "${JANSSON_INSTALL_INCLUDE_DIR}" COMPONENT dev) PUBLIC_HEADER DESTINATION "${JANSSON_INSTALL_INCLUDE_DIR}" COMPONENT dev)
# Install the pkg-config. # Install the pkg-config.
install (FILES install (FILES
${CMAKE_CURRENT_BINARY_DIR}/jansson.pc ${CMAKE_CURRENT_BINARY_DIR}/jansson.pc
DESTINATION ${JANSSON_INSTALL_LIB_DIR}/pkgconfig COMPONENT dev) DESTINATION ${JANSSON_INSTALL_LIB_DIR}/pkgconfig COMPONENT dev)
@ -679,7 +678,7 @@ install(FILES
DESTINATION "${JANSSON_INSTALL_CMAKE_DIR}" COMPONENT dev) DESTINATION "${JANSSON_INSTALL_CMAKE_DIR}" COMPONENT dev)
# Install exports for the install-tree. # Install exports for the install-tree.
install(EXPORT JanssonTargets install(EXPORT JanssonTargets
DESTINATION "${JANSSON_INSTALL_CMAKE_DIR}" COMPONENT dev) DESTINATION "${JANSSON_INSTALL_CMAKE_DIR}" COMPONENT dev)
endif() endif()