1- cmake_minimum_required (VERSION 3.20)
1+ cmake_minimum_required (VERSION 3.20 FATAL_ERROR )
22
3- project ( Waves2AMR
4- LANGUAGES C CXX
5- )
3+ project (Waves2AMR LANGUAGES C CXX)
64
7- message ( STATUS "CMake version: ${CMAKE_VERSION} " )
5+ list ( APPEND CMAKE_MODULE_PATH " ${PROJECT_SOURCE_DIR} /cmake " )
86
9- #
10- # Check if CMAKE_BUILD_TYPE is given. If not, use default
11- #
12- if ( NOT CMAKE_BUILD_TYPE )
13- set (CMAKE_CONFIGURATION_TYPES "Release;Debug;MinSizeRel;RelWithDebInfo" )
14- set (CMAKE_BUILD_TYPE Release
15- CACHE STRING
16- "Choose the build type, e.g. Release, Debug, or RelWithDebInfo." FORCE)
17- else ()
18- message (STATUS "Build type set by user to '${CMAKE_BUILD_TYPE} '." )
19- endif ()
20-
21- #
22- # Options
23- #
247option (WAVES2AMR_ENABLE_MPI "Enable MPI" OFF )
258
269set (WAVES2AMR_GPU_BACKEND_VALUES NONE SYCL CUDA HIP)
@@ -31,9 +14,6 @@ if (NOT WAVES2AMR_GPU_BACKEND IN_LIST WAVES2AMR_GPU_BACKEND_VALUES)
3114 " Must be one of ${WAVES2AMR_GPU_BACKEND_VALUES} " )
3215endif ()
3316
34- #
35- # Find AMReX, check for required components
36- #
3717if (NOT TARGET AMReX::amrex)
3818 set (AMREX_REQUIRED_COMPONENTS 3D DOUBLE)
3919 if (WAVES2AMR_ENABLE_MPI)
@@ -45,58 +25,36 @@ if (NOT TARGET AMReX::amrex)
4525 find_package (AMReX CONFIG REQUIRED ${AMREX_REQUIRED_COMPONENTS} )
4626endif ()
4727
48- #
49- # Enable CUDA if requested
50- #
5128if (WAVES2AMR_GPU_BACKEND STREQUAL "CUDA" )
5229 include (AMReXTargetHelpers)
5330endif ()
5431
55- # FFTW library is required
56- include_directories (${FFTW_DIR} /include /)
57- set (fftw_lib ${FFTW_DIR} /lib/libfftw3.a)
58-
59- #
60- # Define the object library to compile
61- #
6232add_library (waves_2_amr OBJECT)
63- if (BUILD_SHARED_LIBS )
64- set_target_properties (waves_2_amr PROPERTIES POSITION_INDEPENDENT_CODE ON )
65- endif ()
66- # Link required libraries
6733target_link_libraries (waves_2_amr PUBLIC AMReX::amrex)
68- target_link_libraries (waves_2_amr PRIVATE ${fftw_lib} )
34+
35+ find_package (FFTW REQUIRED)
36+ target_link_libraries (waves_2_amr PUBLIC FFTW::FFTW)
37+
6938add_subdirectory (src)
7039add_subdirectory (include )
7140
7241if (WAVES2AMR_GPU_BACKEND STREQUAL "CUDA" )
7342 setup_target_for_cuda_compilation(waves_2_amr)
7443endif ()
7544
76- if ( NOT CMAKE_CXX_FLAGS )
77- target_link_libraries (waves_2_amr PUBLIC AMReX::Flags_CXX)
78- endif ()
79-
80-
81- # Installation rules
8245include (CMakePackageConfigHelpers)
8346include (GNUInstallDirs)
8447
85- # Create non-object library for use as external target
8648add_library (waves_2_amr_api)
87- if (BUILD_SHARED_LIBS )
88- set_target_properties (waves_2_amr_api PROPERTIES POSITION_INDEPENDENT_CODE ON )
89- endif ()
9049target_link_libraries (waves_2_amr_api PUBLIC waves_2_amr)
9150add_library (${PROJECT_NAME} ::waves_2_amr_api ALIAS waves_2_amr)
51+ add_library (${PROJECT_NAME} ::${PROJECT_NAME} ALIAS waves_2_amr)
9252
93- # Collect all headers and make them installable with the target
9453get_target_property (WAVES2AMR_INCLUDES waves_2_amr SOURCES )
9554list (FILTER WAVES2AMR_INCLUDES INCLUDE REGEX "\\ .h" )
9655set_target_properties (
9756 waves_2_amr PROPERTIES PUBLIC_HEADER "${WAVES2AMR_INCLUDES} " )
9857
99- # Install Waves2AMR
10058install (
10159 TARGETS waves_2_amr_api waves_2_amr
10260 EXPORT ${PROJECT_NAME} Targets
@@ -107,7 +65,6 @@ install(
10765 PUBLIC_HEADER DESTINATION include
10866 )
10967
110- # Make Waves2AMR discoverable using `find_package`
11168install (
11269 EXPORT ${PROJECT_NAME} Targets
11370 NAMESPACE ${PROJECT_NAME} ::
0 commit comments