#]=======================================================================]
include_guard(GLOBAL)
-
# Public interface for creating a module library
function(dune_add_library _name)
cmake_parse_arguments(ARG "OBJECT;INTERFACE" "" "" ${ARGN})
set(ARG_NAMESPACE Dune::)
endif()
+ set_property(GLOBAL PROPERTY ${PROJECT_NAME}_HAS_LIB ON)
+
set(alias ${ARG_NAMESPACE}${ARG_EXPORT_NAME})
if(NOT TARGET ${alias})
add_library(${alias} ALIAS ${_name})
if(DEFINED DUNE_INSTALL_LIBDIR)
message(DEPRECATION "DUNE_INSTALL_LIBDIR is deprecated, use CMAKE_INSTALL_LIBDIR instead")
else()
- set(DUNE_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR})
+ # Determine whether this module is header-only
+ # In the case the property is not defined
+ get_property(_has_lib GLOBAL PROPERTY ${PROJECT_NAME}_HAS_LIB SET)
+
+ if(_has_lib)
+ set(DUNE_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR})
+ else()
+ set(DUNE_INSTALL_LIBDIR ${DUNE_INSTALL_NONOBJECTLIBDIR})
+ endif()
endif()
# Set the location of the doc file source. Needed by custom package configuration
# install library export set
install(EXPORT ${_export_set}
- DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${ProjectName}
+ DESTINATION ${DUNE_INSTALL_LIBDIR}/cmake/${ProjectName}
NAMESPACE ${_namespace}
FILE ${_target_file})