update cmake
This commit is contained in:
parent
cf40c88895
commit
7ba9b945de
3 changed files with 32 additions and 6 deletions
|
@ -19,3 +19,31 @@ if(NAMEOF_OPT_BUILD_TESTS)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
|
||||||
|
add_library(${PROJECT_NAME} INTERFACE)
|
||||||
|
target_include_directories(${PROJECT_NAME}
|
||||||
|
INTERFACE
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
$<INSTALL_INTERFACE:include>)
|
||||||
|
|
||||||
|
write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake
|
||||||
|
VERSION ${PROJECT_VERSION}
|
||||||
|
COMPATIBILITY AnyNewerVersion)
|
||||||
|
|
||||||
|
install(TARGETS ${PROJECT_NAME}
|
||||||
|
EXPORT ${PROJECT_NAME}Targets
|
||||||
|
PUBLIC_HEADER DESTINATION include
|
||||||
|
INCLUDES DESTINATION include)
|
||||||
|
|
||||||
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
|
||||||
|
DESTINATION lib/cmake/${PROJECT_NAME})
|
||||||
|
|
||||||
|
install(EXPORT ${PROJECT_NAME}Targets
|
||||||
|
NAMESPACE ${PROJECT_NAME}::
|
||||||
|
DESTINATION lib/cmake/${PROJECT_NAME})
|
||||||
|
|
||||||
|
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||||
|
DESTINATION include)
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
include(CheckCXXCompilerFlag)
|
include(CheckCXXCompilerFlag)
|
||||||
|
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/include)
|
|
||||||
|
|
||||||
set(OPTIONS "")
|
set(OPTIONS "")
|
||||||
|
|
||||||
if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
|
if((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
|
||||||
|
@ -19,5 +17,6 @@ endif()
|
||||||
|
|
||||||
add_executable(example
|
add_executable(example
|
||||||
example.cpp
|
example.cpp
|
||||||
${CMAKE_SOURCE_DIR}/include/nameof.hpp)
|
${CMAKE_SOURCE_DIR}/include/${CMAKE_PROJECT_NAME}.hpp)
|
||||||
target_compile_options(example PRIVATE ${OPTIONS})
|
target_compile_options(example PRIVATE ${OPTIONS})
|
||||||
|
target_link_libraries(example PRIVATE ${CMAKE_PROJECT_NAME})
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
include(CheckCXXCompilerFlag)
|
include(CheckCXXCompilerFlag)
|
||||||
|
|
||||||
include_directories(3rdparty/Catch2)
|
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/include)
|
|
||||||
|
|
||||||
set(SOURCES test.cpp)
|
set(SOURCES test.cpp)
|
||||||
|
|
||||||
set(OPTIONS "")
|
set(OPTIONS "")
|
||||||
|
@ -28,6 +25,8 @@ endif()
|
||||||
function(make_target target std)
|
function(make_target target std)
|
||||||
add_executable(${target} ${SOURCES})
|
add_executable(${target} ${SOURCES})
|
||||||
target_compile_options(${target} PRIVATE ${OPTIONS})
|
target_compile_options(${target} PRIVATE ${OPTIONS})
|
||||||
|
target_include_directories(${target} PRIVATE 3rdparty/Catch2)
|
||||||
|
target_link_libraries(${target} PRIVATE ${CMAKE_PROJECT_NAME})
|
||||||
if(std)
|
if(std)
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||||
target_compile_options(${target} PRIVATE /std:${std})
|
target_compile_options(${target} PRIVATE /std:${std})
|
||||||
|
|
Loading…
Reference in a new issue