diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d8ed55..40142f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,3 +110,68 @@ if (BUILD_TESTING) enable_testing() endif() + + +# ------------------------------------------------------------------ +# cmake install stuff +# ------------------------------------------------------------------ + +set(OWL_CMAKE_INSTALL_DESTINATION + ${CMAKE_INSTALL_LIBDIR}/cmake/owl-${OWL_VERSION} +) + +include(CMakePackageConfigHelpers) + +configure_package_config_file( + "${PROJECT_SOURCE_DIR}/owl/cmake/owlConfig.cmake.in" + "${PROJECT_BINARY_DIR}/owlConfig.cmake" + INSTALL_DESTINATION + ${OWL_CMAKE_INSTALL_DESTINATION} +) + +write_basic_package_version_file( + "owlConfigVersion.cmake" + VERSION ${OWL_VERSION} + COMPATIBILITY SameMajorVersion +) + +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/owlConfig.cmake + ${CMAKE_CURRENT_BINARY_DIR}/owlConfigVersion.cmake + DESTINATION + ${OWL_CMAKE_INSTALL_DESTINATION} + ) + +install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/cmake + DESTINATION + ${OWL_CMAKE_INSTALL_DESTINATION} + FILES_MATCHING + PATTERN *.cmake + PATTERN Findowl.cmake EXCLUDE +) + +set(OWL_INSTALL_TARGETS owl owl_static) + +install( + TARGETS + ${OWL_INSTALL_TARGETS} + EXPORT owl-config + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + NAMELINK_SKIP + # on Windows put the dlls into bin + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + # ... and the import lib into the devel package + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +) +install(EXPORT owl-config + DESTINATION ${OWL_CMAKE_INSTALL_DESTINATION} + NAMESPACE owl:: + ) + +install( +# DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/owl + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/owl + DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR} + ) + + diff --git a/owl/include/owl/common/arrayND/array2D.h b/include/owl/common/arrayND/array2D.h similarity index 100% rename from owl/include/owl/common/arrayND/array2D.h rename to include/owl/common/arrayND/array2D.h diff --git a/owl/include/owl/common/arrayND/array3D.h b/include/owl/common/arrayND/array3D.h similarity index 100% rename from owl/include/owl/common/arrayND/array3D.h rename to include/owl/common/arrayND/array3D.h diff --git a/owl/include/owl/common/math/AffineSpace.h b/include/owl/common/math/AffineSpace.h similarity index 100% rename from owl/include/owl/common/math/AffineSpace.h rename to include/owl/common/math/AffineSpace.h diff --git a/owl/include/owl/common/math/LinearSpace.h b/include/owl/common/math/LinearSpace.h similarity index 100% rename from owl/include/owl/common/math/LinearSpace.h rename to include/owl/common/math/LinearSpace.h diff --git a/owl/include/owl/common/math/Quaternion.h b/include/owl/common/math/Quaternion.h similarity index 100% rename from owl/include/owl/common/math/Quaternion.h rename to include/owl/common/math/Quaternion.h diff --git a/owl/include/owl/common/math/box.h b/include/owl/common/math/box.h similarity index 100% rename from owl/include/owl/common/math/box.h rename to include/owl/common/math/box.h diff --git a/owl/include/owl/common/math/constants.h b/include/owl/common/math/constants.h similarity index 100% rename from owl/include/owl/common/math/constants.h rename to include/owl/common/math/constants.h diff --git a/owl/include/owl/common/math/fixedpoint.h b/include/owl/common/math/fixedpoint.h similarity index 100% rename from owl/include/owl/common/math/fixedpoint.h rename to include/owl/common/math/fixedpoint.h diff --git a/owl/include/owl/common/math/random.h b/include/owl/common/math/random.h similarity index 100% rename from owl/include/owl/common/math/random.h rename to include/owl/common/math/random.h diff --git a/owl/include/owl/common/math/vec.h b/include/owl/common/math/vec.h similarity index 100% rename from owl/include/owl/common/math/vec.h rename to include/owl/common/math/vec.h diff --git a/owl/include/owl/common/math/vec/compare.h b/include/owl/common/math/vec/compare.h similarity index 100% rename from owl/include/owl/common/math/vec/compare.h rename to include/owl/common/math/vec/compare.h diff --git a/owl/include/owl/common/math/vec/functors.h b/include/owl/common/math/vec/functors.h similarity index 100% rename from owl/include/owl/common/math/vec/functors.h rename to include/owl/common/math/vec/functors.h diff --git a/owl/include/owl/common/math/vec/rotate.h b/include/owl/common/math/vec/rotate.h similarity index 100% rename from owl/include/owl/common/math/vec/rotate.h rename to include/owl/common/math/vec/rotate.h diff --git a/owl/include/owl/common/owl-common.h b/include/owl/common/owl-common.h similarity index 100% rename from owl/include/owl/common/owl-common.h rename to include/owl/common/owl-common.h diff --git a/owl/include/owl/common/parallel/parallel_for.cpp b/include/owl/common/parallel/parallel_for.cpp similarity index 100% rename from owl/include/owl/common/parallel/parallel_for.cpp rename to include/owl/common/parallel/parallel_for.cpp diff --git a/owl/include/owl/common/parallel/parallel_for.h b/include/owl/common/parallel/parallel_for.h similarity index 100% rename from owl/include/owl/common/parallel/parallel_for.h rename to include/owl/common/parallel/parallel_for.h diff --git a/include/owl/owl_host.h b/include/owl/owl_host.h index 366776e..bdb77a6 100644 --- a/include/owl/owl_host.h +++ b/include/owl/owl_host.h @@ -26,28 +26,30 @@ # define OWL_CAN_DO_SPHERES 1 #endif - -#if defined(_MSC_VER) -# define OWL_DLL_EXPORT __declspec(dllexport) -# define OWL_DLL_IMPORT __declspec(dllimport) +#ifdef _WIN32 +# if defined(owl_STATIC) || defined(owl_mpi_STATIC) +# define OWL_INTERFACE /* nothing */ +# elif defined(owl_EXPORTS) || defined(owl_mpi_EXPORTS) +# define OWL_INTERFACE __declspec(dllexport) +# else +# define OWL_INTERFACE __declspec(dllimport) +# endif #elif defined(__clang__) || defined(__GNUC__) -# define OWL_DLL_EXPORT __attribute__((visibility("default"))) -# define OWL_DLL_IMPORT __attribute__((visibility("default"))) +# define OWL_INTERFACE __attribute__((visibility("default"))) #else -# define OWL_DLL_EXPORT -# define OWL_DLL_IMPORT +# define OWL_INTERFACE #endif #ifdef __cplusplus -# define OWL_IF_CPP(a) a +# define OWL_IF_CPP(a) a #else -# define OWL_IF_CPP(a) /* drop it */ +# define OWL_IF_CPP(a) /* ignore */ #endif # ifdef __cplusplus -# define OWL_API extern "C" OWL_DLL_EXPORT +# define OWL_API extern "C" OWL_INTERFACE # else -# define OWL_API /* bla */ +# define OWL_API /* bla */ OWL_INTERFACE # endif diff --git a/owl/CMakeLists.txt b/owl/CMakeLists.txt index 55e3f20..b954a68 100644 --- a/owl/CMakeLists.txt +++ b/owl/CMakeLists.txt @@ -9,28 +9,28 @@ set(OWL_SOURCES # ------------------------------------------------------- # infrastructure # ------------------------------------------------------- - include/owl/owl.h - include/owl/owl_host.h - include/owl/owl_device.h - include/owl/common/arrayND/array2D.h - include/owl/common/arrayND/array3D.h - include/owl/common/math/AffineSpace.h - include/owl/common/math/box.h - include/owl/common/math/constants.h - include/owl/common/math/fixedpoint.h - include/owl/common/math/LinearSpace.h - include/owl/common/math/Quaternion.h - include/owl/common/math/random.h - include/owl/common/math/vec/compare.h - include/owl/common/math/vec/functors.h - include/owl/common/math/vec/rotate.h - include/owl/common/math/vec.h - include/owl/common/owl-common.h - include/owl/common/parallel/parallel_for.h - include/owl/owl.h - include/owl/owl_device.h - include/owl/owl_device_buffer.h - include/owl/owl_host.h + ../include/owl/owl.h + ../include/owl/owl_host.h + ../include/owl/owl_device.h + ../include/owl/common/arrayND/array2D.h + ../include/owl/common/arrayND/array3D.h + ../include/owl/common/math/AffineSpace.h + ../include/owl/common/math/box.h + ../include/owl/common/math/constants.h + ../include/owl/common/math/fixedpoint.h + ../include/owl/common/math/LinearSpace.h + ../include/owl/common/math/Quaternion.h + ../include/owl/common/math/random.h + ../include/owl/common/math/vec/compare.h + ../include/owl/common/math/vec/functors.h + ../include/owl/common/math/vec/rotate.h + ../include/owl/common/math/vec.h + ../include/owl/common/owl-common.h + ../include/owl/common/parallel/parallel_for.h +# ../include/owl/owl.h +# ../include/owl/owl_device.h +# ../include/owl/owl_device_buffer.h +# ../include/owl/owl_host.h helper/cuda.h helper/optix.h common.h @@ -150,8 +150,17 @@ target_link_libraries(owl-config INTERFACE if (OWL_CUDA_STATIC) target_compile_definitions(owl-config INTERFACE -DOWL_CUDA_STATIC=1) endif() -target_link_libraries(owl PUBLIC owl-config) -target_link_libraries(owl_static PUBLIC owl-config) +target_link_libraries(owl PUBLIC + $ +) +target_link_libraries(owl_static PUBLIC + $ +) +if (APPLE) + set_target_properties(owl PROPERTIES INSTALL_RPATH "$loader_path") +else() + set_target_properties(owl PROPERTIES INSTALL_RPATH "$ORIGIN") +endif() if (OWL_HAVE_TBB AND TBB_FOUND) if (TARGET TBB::tbb) @@ -183,7 +192,8 @@ endif() target_include_directories(owl-config INTERFACE ${PROJECT_SOURCE_DIR} - ${CMAKE_CURRENT_LIST_DIR}/include + $ + #CMAKE_CURRENT_LIST_DIR}/include ) if (WIN32) diff --git a/owl/cmake/owlConfig.cmake.in b/owl/cmake/owlConfig.cmake.in new file mode 100644 index 0000000..f030e85 --- /dev/null +++ b/owl/cmake/owlConfig.cmake.in @@ -0,0 +1,43 @@ +## Copyright 2021-2024 The Khronos Group +## SPDX-License-Identifier: Apache-2.0 + +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) + +set(THREADS_PREFER_PTHREAD_FLAG ON) +find_dependency(Threads) + +include(${CMAKE_CURRENT_LIST_DIR}/owl-config.cmake) + +if (NOT TARGET owl::owl) + message(FATAL_ERROR "CMAKE_PREFIX_PATH or owl_DIR are pointing to a \ + owl build directory. Please do a full install of owl \ + (e.g. 'make install') and point to where you installed it \ + (CMAKE_INSTALL_PREFIX in your build of owl). \ + Consuming owl from a build directory is not supported.") +endif() +set(owl_FOUND ON) + +set(OWL_DATAROOTDIR + ${CMAKE_CURRENT_LIST_DIR}/../../../@CMAKE_INSTALL_DATAROOTDIR@/owl + ) + +if (@OWL_MPI@) + find_dependency(MPI) + set(OWL_FEATURE_MPI ON) +endif() + + +foreach(component ${owl_FIND_COMPONENTS}) + # For requested component, execute its "config" script + message("cfind component ${component}") + if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/${component}-config.cmake") + include(${CMAKE_CURRENT_LIST_DIR}/${component}-config.cmake) + set(${component}_FOUND ON) + else() + set(${component}_FOUND OFF) + endif() +endforeach() + +check_required_components(@PROJECT_NAME@) diff --git a/owl/include/owl/owl.h b/owl/deprecated-include/owl/owl.h similarity index 100% rename from owl/include/owl/owl.h rename to owl/deprecated-include/owl/owl.h diff --git a/owl/include/owl/owl_device.h b/owl/deprecated-include/owl/owl_device.h similarity index 100% rename from owl/include/owl/owl_device.h rename to owl/deprecated-include/owl/owl_device.h diff --git a/owl/include/owl/owl_host.h b/owl/deprecated-include/owl/owl_host.h similarity index 100% rename from owl/include/owl/owl_host.h rename to owl/deprecated-include/owl/owl_host.h diff --git a/owl/include/owl/pyOWL.h b/owl/deprecated-include/owl/pyOWL.h similarity index 100% rename from owl/include/owl/pyOWL.h rename to owl/deprecated-include/owl/pyOWL.h diff --git a/owl/include/owl/owl_device_buffer.h b/owl/owl_device_buffer.h similarity index 94% rename from owl/include/owl/owl_device_buffer.h rename to owl/owl_device_buffer.h index edc85fb..a6a1184 100644 --- a/owl/include/owl/owl_device_buffer.h +++ b/owl/owl_device_buffer.h @@ -5,7 +5,7 @@ #pragma once -#include "owl_host.h" +#include "owl/owl_host.h" namespace owl { namespace device {