diff --git a/CMakeLists.txt b/CMakeLists.txt index 072805c..21757f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,6 +83,7 @@ fortuno_setup_build_type("RelWithDebInfo") # Main definition # ]=================================================================================================] +add_subdirectory(include) add_subdirectory(src) if (FORTUNO_BUILD_EXAMPLES) add_subdirectory(example) @@ -143,22 +144,6 @@ if (FORTUNO_INSTALL) DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Fortuno COMPONENT Fortuno_development ) - install( - FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/fortuno.fypp - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" - COMPONENT Fortuno_development - ) - # introduce fake target with information about the folder containing the include file - add_library(fortuno_include_dir INTERFACE) - target_include_directories( - fortuno_include_dir INTERFACE - $ - $ - ) - install( - TARGETS fortuno_include_dir - EXPORT FortunoTargets - ) endif () diff --git a/example/fypp/CMakeLists.txt b/example/fypp/CMakeLists.txt index 03f0cf6..096463e 100644 --- a/example/fypp/CMakeLists.txt +++ b/example/fypp/CMakeLists.txt @@ -26,8 +26,10 @@ set( parametrized_fypp_tests.fypp simple_fypp_tests.fypp ) + +get_target_property(_fortuno_incdir Fortuno::fortuno_include_dir INTERFACE_INCLUDE_DIRECTORIES) fortuno_preprocess( - ${FYPP} "-I${CMAKE_SOURCE_DIR}/include;--file-var-root=${CMAKE_SOURCE_DIR}" + ${FYPP} "-I${_fortuno_incdir};--file-var-root=${CMAKE_SOURCE_DIR}" .fypp .f90 "${fypp-sources}" fypp-f90-sources ) diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt new file mode 100644 index 0000000..a6017b1 --- /dev/null +++ b/include/CMakeLists.txt @@ -0,0 +1,25 @@ +# This file is part of Fortuno. +# Licensed under the BSD-2-Clause Plus Patent license. +# SPDX-License-Identifier: BSD-2-Clause-Patent + +# Introduce a fake target associated with the location of the folder containing the include file. +# Query the INTERFACE_INCLUDE_DIRECTORIES of the target to obtain the include folder location. +add_library(fortuno_include_dir INTERFACE) +target_include_directories( + fortuno_include_dir INTERFACE + $ + $ +) +add_library(Fortuno::fortuno_include_dir ALIAS fortuno_include_dir) + +if (FORTUNO_INSTALL) + install( + FILES fortuno.fypp + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + COMPONENT Fortuno_development + ) + install( + TARGETS fortuno_include_dir + EXPORT FortunoTargets + ) +endif () \ No newline at end of file