Unverified Commit c5dd200a authored by Dennis Jenkins's avatar Dennis Jenkins Committed by GitHub

Merge pull request #409 from hwaan2/change_cmake

Change Cmakefiles > Issue #357 
parents c5ff6f9a b871e25f
......@@ -23,6 +23,12 @@ else()
# Following workaround forces Clang to compile at best with C++14
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_STANDARD 14)
elseif (CMAKE_COMPILER_IS_GNUCC)
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
set(CMAKE_CXX_STANDARD 17)
else()
set(CMAKE_CXX_STANDARD 14)
endif()
else()
set(CMAKE_CXX_STANDARD 17)
endif()
......@@ -31,25 +37,6 @@ else()
endif()
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
add_subdirectory (src)
if (PISTACHE_BUILD_EXAMPLES)
add_subdirectory (examples)
endif()
if (PISTACHE_BUILD_TESTS)
find_package(GTest)
if (GTEST_FOUND)
include_directories(${GTEST_INCLUDE_DIRS})
else()
ADD_SUBDIRECTORY (googletest-release-1.7.0)
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
endif()
enable_testing()
add_subdirectory(tests)
endif()
# Set version...
# Major and minor version...
......@@ -110,3 +97,21 @@ if(PISTACHE_INSTALL)
)
endif()
add_subdirectory (src)
if (PISTACHE_BUILD_EXAMPLES)
add_subdirectory (examples)
endif()
if (PISTACHE_BUILD_TESTS)
find_package(GTest)
if (GTEST_FOUND)
include_directories(${GTEST_INCLUDE_DIRS})
else()
ADD_SUBDIRECTORY (googletest-release-1.7.0)
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
endif()
enable_testing()
add_subdirectory(tests)
endif()
......@@ -3,7 +3,7 @@ function(pistache_example example_name)
set(EXAMPLE_SOURCE ${example_name}.cc)
add_executable(${EXAMPLE_EXECUTABLE} ${EXAMPLE_SOURCE})
target_link_libraries(${EXAMPLE_EXECUTABLE} pistache)
target_link_libraries(${EXAMPLE_EXECUTABLE} pistache_static)
endfunction()
pistache_example(http_server)
......
......@@ -11,12 +11,8 @@ set(SOURCE_FILES
${INCLUDE_FILES}
)
add_library(pistache ${SOURCE_FILES})
set_target_properties(pistache PROPERTIES
OUTPUT_NAME "pistache"
VERSION ${GENERIC_LIB_VERSION}
SOVERSION ${GENERIC_LIB_SOVERSION}
)
add_library(pistache OBJECT ${SOURCE_FILES})
set_target_properties(pistache PROPERTIES POSITION_INDEPENDENT_CODE 1)
add_definitions(-DONLY_C_LOCALE=1)
target_include_directories(pistache PUBLIC
......@@ -27,11 +23,23 @@ set(include_install_dir "include")
set(lib_install_dir "lib/")
set(bin_install_dir "bin/")
target_link_libraries(pistache pthread)
add_library(pistache_shared SHARED $<TARGET_OBJECTS:pistache>)
add_library(pistache_static STATIC $<TARGET_OBJECTS:pistache>)
target_link_libraries(pistache_shared pthread)
target_link_libraries(pistache_static pthread)
set_target_properties(pistache_shared PROPERTIES
OUTPUT_NAME "pistache"
VERSION ${version}
SOVERSION ${VERSION_MAJOR}
)
set_target_properties(pistache_static PROPERTIES OUTPUT_NAME "pistache")
if (PISTACHE_INSTALL)
install(
TARGETS pistache
TARGETS pistache_shared
EXPORT ${targets_export_name}
ARCHIVE DESTINATION ${lib_install_dir}
LIBRARY DESTINATION ${lib_install_dir}
......@@ -42,7 +50,7 @@ if (PISTACHE_INSTALL)
DIRECTORY "${PROJECT_SOURCE_DIR}/include/pistache"
DESTINATION ${include_install_dir}
FILES_MATCHING PATTERN "*.*h")
install(TARGETS pistache
install(TARGETS pistache_static
EXPORT PistacheTargets
DESTINATION lib)
install(EXPORT PistacheTargets
......
......@@ -3,7 +3,7 @@ function(pistache_test test_name)
set(TEST_SOURCE ${test_name}.cc)
add_executable(${TEST_EXECUTABLE} ${TEST_SOURCE})
target_link_libraries(${TEST_EXECUTABLE} gtest gtest_main pistache curl pthread)
target_link_libraries(${TEST_EXECUTABLE} gtest gtest_main pistache_static curl pthread)
add_test(${test_name} ${TEST_EXECUTABLE})
endfunction()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment