mirror of
https://github.com/simonbrunel/qtpromise.git
synced 2024-11-23 19:20:57 +08:00
Add project install/export in CMakeLists.txt
Signed-off-by: Marc Reilly <marc@cpdesign.com.au>
This commit is contained in:
parent
461f09bef8
commit
c181965a1c
@ -10,6 +10,8 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
||||
|
||||
find_package(Qt5 5.6.0 REQUIRED COMPONENTS Core)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
@ -18,7 +20,11 @@ add_library(qtpromise INTERFACE)
|
||||
add_library(qtpromise::qtpromise ALIAS qtpromise)
|
||||
|
||||
target_link_libraries(qtpromise INTERFACE Qt5::Core)
|
||||
target_include_directories(qtpromise INTERFACE "${CMAKE_CURRENT_LIST_DIR}/include")
|
||||
target_include_directories(qtpromise
|
||||
INTERFACE
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
|
||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/qtpromise/include>"
|
||||
)
|
||||
|
||||
add_definitions(
|
||||
-DQT_DEPRECATED_WARNINGS
|
||||
@ -79,6 +85,46 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
)
|
||||
endif()
|
||||
|
||||
install(
|
||||
TARGETS ${PROJECT_NAME}
|
||||
EXPORT ${PROJECT_NAME}_Targets
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Runtime
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Runtime
|
||||
)
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
write_basic_package_version_file(
|
||||
"qtpromiseConfigVersion.cmake"
|
||||
VERSION ${PROJECT_VERSION}
|
||||
COMPATIBILITY SameMajorVersion
|
||||
)
|
||||
|
||||
configure_package_config_file(
|
||||
"${PROJECT_SOURCE_DIR}/cmake/qtpromiseConfig.cmake.in"
|
||||
"${PROJECT_BINARY_DIR}/qtpromiseConfig.cmake"
|
||||
INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/qtpromise/cmake
|
||||
)
|
||||
|
||||
install(
|
||||
EXPORT ${PROJECT_NAME}_Targets
|
||||
FILE qtpromiseTargets.cmake
|
||||
NAMESPACE qtpromise::
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/qtpromise/cmake
|
||||
)
|
||||
|
||||
install(
|
||||
FILES "${PROJECT_BINARY_DIR}/qtpromiseConfig.cmake"
|
||||
"${PROJECT_BINARY_DIR}/qtpromiseConfigVersion.cmake"
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/qtpromise/cmake
|
||||
)
|
||||
|
||||
install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/qtpromise
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/qtpromise/src)
|
||||
install(FILES ${PROJECT_SOURCE_DIR}/include/QtPromise
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/qtpromise/include)
|
||||
|
||||
|
||||
if(NOT SUBPROJECT)
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
|
5
cmake/qtpromiseConfig.cmake.in
Normal file
5
cmake/qtpromiseConfig.cmake.in
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
@PACKAGE_INIT@
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
|
||||
check_required_components("@PROJECT_NAME@")
|
Loading…
Reference in New Issue
Block a user