From f334b289795e267012b2d79f8787a1e4ac6aabab Mon Sep 17 00:00:00 2001 From: Noah <37805707+Curve@users.noreply.github.com> Date: Fri, 2 Feb 2024 13:55:08 +0100 Subject: [PATCH] Use Package Project (#103) * feat: use package-project * fix: formatting * fix: local installs via `find_package` * fix: formatting --- CMakeLists.txt | 38 +++++++++++++++++++------------------- README.md | 20 ++++++++++++-------- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e3651caa..287bf244 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.14 FATAL_ERROR) +cmake_minimum_required(VERSION 3.20 FATAL_ERROR) project( ViennaLS LANGUAGES CXX @@ -78,7 +78,7 @@ endif() target_include_directories( ${PROJECT_NAME} INTERFACE $ - $) + $) # -------------------------------------------------------------------------------------------------------- # Setup Dependencies @@ -86,11 +86,15 @@ target_include_directories( 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) + VERSION 0.4.0 + GIT_REPOSITORY "https://github.com/ViennaTools/ViennaHRLE") find_package(OpenMP REQUIRED) target_link_libraries(${PROJECT_NAME} INTERFACE OpenMP::OpenMP_CXX ViennaHRLE) @@ -126,7 +130,8 @@ if(VIENNALS_USE_VTK) "VTK_MODULE_ENABLE_VTK_FiltersCore YES" "VTK_MODULE_ENABLE_VTK_FiltersGeneral YES" "VTK_MODULE_ENABLE_VTK_FiltersGeometry YES" - EXCLUDE_FROM_ALL ON) + # This fixes an issue with the install script that causes find_package to fail. + "CMAKE_PROJECT_NAME VTK") target_compile_definitions(${PROJECT_NAME} INTERFACE VIENNALS_USE_VTK=1) @@ -205,16 +210,11 @@ 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} NAMESPACE ViennaTools + VERSION ${PROJECT_VERSION} + BINARY_DIR ${PROJECT_BINARY_DIR} + INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include/viennals + INCLUDE_DESTINATION include/viennals-${PROJECT_VERSION} + COMPATIBILITY SameMajorVersion + DEPENDENCIES "VTK 9.0.0;ViennaHRLE 0.4.0") diff --git a/README.md b/README.md index ac66f797..fc3defeb 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,8 @@

ViennaLS

-[![Linux](https://github.com/ViennaTools/ViennaLS/actions/workflows/linux_test.yml/badge.svg)](https://github.com/ViennaTools/ViennaLS/actions/workflows/linux_test.yml) -[![macOS](https://github.com/ViennaTools/ViennaLS/actions/workflows/macos_test.yml/badge.svg)](https://github.com/ViennaTools/ViennaLS/actions/workflows/macos_test.yml) -[![Windows](https://github.com/ViennaTools/ViennaLS/actions/workflows/windows_test.yml/badge.svg)](https://github.com/ViennaTools/ViennaLS/actions/workflows/windows_test.yml) +[![๐Ÿงช Tests](https://github.com/ViennaTools/ViennaLS/actions/workflows/test.yml/badge.svg)](https://github.com/ViennaTools/ViennaLS/actions/workflows/test.yml) +[![๐Ÿ Build Bindings](https://github.com/ViennaTools/ViennaLS/actions/workflows/python.yml/badge.svg)](https://github.com/ViennaTools/ViennaLS/actions/workflows/python.yml) @@ -144,12 +143,17 @@ We recommend using [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake) to consum ``` * With a local installation - > In case you have ViennaLS installed in a custom directory, make sure to properly specify the `CMAKE_MODULE_PATH` + > In case you have ViennaLS installed in a custom directory, make sure to properly specify the `CMAKE_MODULE_PATH` or `PATHS` in your `find_package` call. - ```cmake - find_package(ViennaLS REQUIRED) - target_link_libraries(${PROJECT_NAME} ViennaTools::ViennaLS) + set(VIENNALS_PATH "/your/local/installation") + + find_package(OpenMP REQUIRED) + find_package(VTK PATHS ${VIENNALS_PATH}) + find_package(ViennaHRLE PATHS ${VIENNALS_PATH}) + find_package(ViennaLS PATHS ${VIENNALS_PATH}) + + target_link_libraries(${PROJECT_NAME} PUBLIC ViennaTools::ViennaLS) ``` ### Shared Library @@ -176,7 +180,7 @@ Founder and initial developer: Otmar Ertl Contact us via: viennats@iue.tuwien.ac.at -ViennaLS was developed under the aegis of the 'Institute for Microelectronics' at the 'TU Wien'. +ViennaLS was developed under the aegis of the 'Institute for Microelectronics' at the 'TU Wien'. http://www.iue.tuwien.ac.at/ ## License