Skip to content

Commit

Permalink
Use Package Project (#103)
Browse files Browse the repository at this point in the history
* feat: use package-project

* fix: formatting

* fix: local installs via `find_package`

* fix: formatting
  • Loading branch information
Curve authored Feb 2, 2024
1 parent 57fa5b9 commit f334b28
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 27 deletions.
38 changes: 19 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)
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)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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")
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

<h1>ViennaLS</h1>

[![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)

</div>

Expand Down Expand Up @@ -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
Expand All @@ -176,7 +180,7 @@ Founder and initial developer: Otmar Ertl

Contact us via: [email protected]

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
Expand Down

0 comments on commit f334b28

Please sign in to comment.