diff --git a/CMakeLists.txt b/CMakeLists.txt index d5414b1a068f3da20c0fd65b6ba3278c38a14205..4c6e936a2ea332853a75e893ce2ee994a0d07e04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -133,7 +133,6 @@ endif(CM_ALL_AUTO_DOC) # Export targets and create package - install(EXPORT ALLTargets NAMESPACE ALL:: FILE ALLTargets.cmake @@ -154,5 +153,24 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ALLConfigVersion.cmake" DESTINATION lib/cmake/ALL) +# Create Makefile.libALL.in for inclusion in external Makefile projects +# todo(s.schulz): The include directories and libraries should be auto +# detected... but that is not easily done right now. Ideally, this should also +# provide the very long VTK linker flags. +set(ALL_MAKEFILE_INC ${CMAKE_CURRENT_BINARY_DIR}/Makefile.libALL.in) +get_target_property(_liball_defines ALL INTERFACE_COMPILE_DEFINITIONS) +list(TRANSFORM _liball_defines PREPEND " -D") +list(JOIN _liball_defines " " _liball_defines_string) +file(WRITE ${ALL_MAKEFILE_INC} "LIBALL_DEFINES := ${_liball_defines_string}\n") +file(APPEND ${ALL_MAKEFILE_INC} "LIBALL_INCLUDE := -I\$(ALL_DIR)/include\n") +file(APPEND ${ALL_MAKEFILE_INC} "LIBALL_LIB :=\n") +if(CM_ALL_FORTRAN) + file(APPEND ${ALL_MAKEFILE_INC} "LIBALL_LIB += \$(ALL_DIR)/lib/libALL_fortran.a \$(ALL_DIR)/lib/libALL.a -lstdc++\n") + file(APPEND ${ALL_MAKEFILE_INC} "LIBALL_INCLUDE += -I\$(ALL_DIR)/include/modules\n") +endif() +if(CM_ALL_VORONOI) + file(APPEND ${ALL_MAKEFILE_INC} "LIBALL_LIB += \$(ALL_DIR)/lib/libvoro.a\n") +endif() +install(FILES ${ALL_MAKEFILE_INC} DESTINATION lib/make) # vim: sw=4 ts=4 et diff --git a/example/MakefileProject/Makefile b/example/MakefileProject/Makefile index 6738a321e8d3c6668ff994ce8aa218db9c50d638..26d47b37fa1bf4b03730f02ed3532f836a652978 100644 --- a/example/MakefileProject/Makefile +++ b/example/MakefileProject/Makefile @@ -19,18 +19,20 @@ MFC=mpifort ALL_DIR=all_bin VTK_DIR=vtk_bin +# Source tree and temporary build directory ALL_BUILD=all_build ALL_SOURCE=all ALL_SOURCE=../.. -LIBALL_INCLUDE := -I$(ALL_DIR)/include/modules -I$(ALL_DIR)/include -LIBALL_LIB := $(ALL_DIR)/lib/libALL_fortran.a $(ALL_DIR)/lib/libALL.a -LIBALL_LIB += $(ALL_DIR)/lib/libvoro.a -LIBALL_CONFIG_FILE := $(ALL_DIR)/lib/cmake/ALL/ALLConfig.cmake -LIBALL_DEFINES += -DALL_VTK_OUTPUT -DALL_VORONOI_ACTIVE - +# Which features should be enabled for ALL LIBALL_CONFIGURE := -DCM_ALL_FORTRAN=ON -DCM_ALL_VORONOI=ON -DCM_ALL_VTK_OUTPUT=ON -DCMAKE_BUILD_TYPE=Release + +LIBALL_CONFIG_FILE := $(ALL_DIR)/lib/make/Makefile.libALL.in +# This will provide the variables LIBALL_DEFINES, LIBALL_INCLUDE and +# LIBALL_LIB, which need to be passed to the compiler and linker. +-include $(LIBALL_CONFIG_FILE) + # Since gfortran does not link the standard C++ library by default, we need to # explicitly state it. FFLAGS += -lstdc++