Skip to content

Commit

Permalink
feat: use package-project
Browse files Browse the repository at this point in the history
  • Loading branch information
Curve committed Dec 12, 2023
1 parent 57fa5b9 commit 4d7781d
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
project(
ViennaLS
LANGUAGES CXX
Expand Down Expand Up @@ -78,19 +78,23 @@ endif()

target_include_directories(
${PROJECT_NAME} INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/viennals>
$<INSTALL_INTERFACE:include/viennals>)
$<INSTALL_INTERFACE:include/viennals-${PROJECT_VERSION}>)

# --------------------------------------------------------------------------------------------------------
# Setup Dependencies
# --------------------------------------------------------------------------------------------------------

include("cmake/cpm.cmake")

CPMAddPackage(
NAME PackageProject
VERSION 1.11.1
GIT_REPOSITORY "https://github.com/TheLartians/PackageProject.cmake")

CPMFindPackage(
NAME ViennaHRLE
GIT_TAG master
GIT_REPOSITORY "https://github.com/ViennaTools/ViennaHRLE"
EXCLUDE_FROM_ALL ON)
GIT_REPOSITORY "https://github.com/ViennaTools/ViennaHRLE")

find_package(OpenMP REQUIRED)
target_link_libraries(${PROJECT_NAME} INTERFACE OpenMP::OpenMP_CXX ViennaHRLE)
Expand Down Expand Up @@ -125,8 +129,7 @@ if(VIENNALS_USE_VTK)
"VTK_MODULE_ENABLE_VTK_IOXML YES"
"VTK_MODULE_ENABLE_VTK_FiltersCore YES"
"VTK_MODULE_ENABLE_VTK_FiltersGeneral YES"
"VTK_MODULE_ENABLE_VTK_FiltersGeometry YES"
EXCLUDE_FROM_ALL ON)
"VTK_MODULE_ENABLE_VTK_FiltersGeometry YES")

target_compile_definitions(${PROJECT_NAME} INTERFACE VIENNALS_USE_VTK=1)

Expand Down Expand Up @@ -205,16 +208,10 @@ endif()
# Install Target
# --------------------------------------------------------------------------------------------------------

install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-config
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

install(
EXPORT ${PROJECT_NAME}-config
FILE ${PROJECT_NAME}-config.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})

install(DIRECTORY "include/viennals" TYPE INCLUDE)
packageProject(
NAME ${PROJECT_NAME}
VERSION ${PROJECT_VERSION}
BINARY_DIR ${PROJECT_BINARY_DIR}
INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include/viennals
INCLUDE_DESTINATION include/viennals-${PROJECT_VERSION}
)

0 comments on commit 4d7781d

Please sign in to comment.