mirror of
https://github.com/lifegpc/c-utils.git
synced 2026-06-06 21:28:50 +08:00
add more flags
This commit is contained in:
@@ -1,6 +1,19 @@
|
||||
cmake_minimum_required(VERSION 3.17)
|
||||
|
||||
option(ENABLE_ICONV "Use libiconv to convert encoding" ON)
|
||||
option(ENABLE_STANDALONE "Build utils standalone" OFF)
|
||||
option(ENABLE_CXX17 "Enable C++ 17" OFF)
|
||||
option(INSTALL_DEP_FILES "Install a file with dependences." OFF)
|
||||
|
||||
if (ENABLE_STANDALONE)
|
||||
project(utils)
|
||||
include(GNUInstallDirs)
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
add_compile_options(/utf-8)
|
||||
add_compile_options(/EHsc)
|
||||
endif()
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
@@ -89,3 +102,19 @@ endif()
|
||||
if (NOT MSVC)
|
||||
target_link_libraries(utils m)
|
||||
endif()
|
||||
if (WIN32)
|
||||
target_link_libraries(utils shell32)
|
||||
endif()
|
||||
if (ENABLE_CXX17)
|
||||
target_compile_features(utils PRIVATE cxx_std_17)
|
||||
endif()
|
||||
if (ENABLE_STANDALONE)
|
||||
install(TARGETS utils)
|
||||
endif()
|
||||
if (INSTALL_DEP_FILES)
|
||||
get_target_property(OUT utils LINK_LIBRARIES)
|
||||
if (OUT)
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/utils_dep.txt" "${OUT}")
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/utils_dep.txt" DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user