Commit c2caf7f1 authored by hwaan2's avatar hwaan2

Modify CMakeLists.txt >

Update GCC Version Check and CXX_STANDARD Setting
Issue #357 > Add Target  pistache_shared, pistache_static
parent c5ff6f9a
...@@ -23,6 +23,12 @@ else() ...@@ -23,6 +23,12 @@ else()
# Following workaround forces Clang to compile at best with C++14 # Following workaround forces Clang to compile at best with C++14
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_STANDARD 14) 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() else()
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
endif() endif()
...@@ -31,25 +37,6 @@ else() ...@@ -31,25 +37,6 @@ else()
endif() endif()
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) 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... # Set version...
# Major and minor version... # Major and minor version...
...@@ -110,3 +97,21 @@ if(PISTACHE_INSTALL) ...@@ -110,3 +97,21 @@ if(PISTACHE_INSTALL)
) )
endif() 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()
...@@ -11,12 +11,8 @@ set(SOURCE_FILES ...@@ -11,12 +11,8 @@ set(SOURCE_FILES
${INCLUDE_FILES} ${INCLUDE_FILES}
) )
add_library(pistache ${SOURCE_FILES}) add_library(pistache OBJECT ${SOURCE_FILES})
set_target_properties(pistache PROPERTIES set_target_properties(pistache PROPERTIES POSITION_INDEPENDENT_CODE 1)
OUTPUT_NAME "pistache"
VERSION ${GENERIC_LIB_VERSION}
SOVERSION ${GENERIC_LIB_SOVERSION}
)
add_definitions(-DONLY_C_LOCALE=1) add_definitions(-DONLY_C_LOCALE=1)
target_include_directories(pistache PUBLIC target_include_directories(pistache PUBLIC
...@@ -27,11 +23,23 @@ set(include_install_dir "include") ...@@ -27,11 +23,23 @@ set(include_install_dir "include")
set(lib_install_dir "lib/") set(lib_install_dir "lib/")
set(bin_install_dir "bin/") 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) if (PISTACHE_INSTALL)
install( install(
TARGETS pistache TARGETS pistache_shared
EXPORT ${targets_export_name} EXPORT ${targets_export_name}
ARCHIVE DESTINATION ${lib_install_dir} ARCHIVE DESTINATION ${lib_install_dir}
LIBRARY DESTINATION ${lib_install_dir} LIBRARY DESTINATION ${lib_install_dir}
...@@ -42,7 +50,7 @@ if (PISTACHE_INSTALL) ...@@ -42,7 +50,7 @@ if (PISTACHE_INSTALL)
DIRECTORY "${PROJECT_SOURCE_DIR}/include/pistache" DIRECTORY "${PROJECT_SOURCE_DIR}/include/pistache"
DESTINATION ${include_install_dir} DESTINATION ${include_install_dir}
FILES_MATCHING PATTERN "*.*h") FILES_MATCHING PATTERN "*.*h")
install(TARGETS pistache install(TARGETS pistache_static
EXPORT PistacheTargets EXPORT PistacheTargets
DESTINATION lib) DESTINATION lib)
install(EXPORT PistacheTargets install(EXPORT PistacheTargets
......
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