|
8 | 8 | # directory. |
9 | 9 | # |
10 | 10 |
|
11 | | -cmake_minimum_required(VERSION 3.0.2) |
| 11 | +cmake_minimum_required(VERSION 3.10.2) |
12 | 12 |
|
13 | 13 | project(Fenix C) |
14 | 14 | # The version number. |
15 | 15 | set(FENIX_VERSION_MAJOR 1) |
16 | 16 | set(FENIX_VERSION_MINOR 0) |
17 | 17 |
|
18 | | -option(BUILD_EXAMPLES "Builds example programs from the examples directory" OFF) |
19 | | -option(BUILD_TESTING "Builds tests and test modes of files" ON) |
| 18 | +option(BUILD_EXAMPLES "Builds example programs from the examples directory" OFF) |
| 19 | +option(BUILD_TESTING "Builds tests and test modes of files" ON) |
20 | 20 |
|
21 | 21 |
|
22 | | -# Set empty string for shared linking (we use static library only at this moment) |
23 | | -set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS) |
| 22 | +#Solves an issue with some system environments putting their MPI headers before |
| 23 | +#the headers CMake includes. Forces non-system MPI headers when incorrect headers |
| 24 | +#detected in include path. |
| 25 | +option(FENIX_SYSTEM_INC_FIX "Attempts to force overriding any system MPI headers" ON) |
| 26 | +option(FENIX_PROPAGATE_INC_FIX "Attempt overriding system MPI headers in linking projects" ON) |
24 | 27 |
|
25 | | -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
26 | | -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
| 28 | +find_package(MPI REQUIRED) |
27 | 29 |
|
28 | | -#set(CMAKE_BUILD_TYPE Release) |
29 | | -set(CMAKE_BUILD_TYPE Debug) |
30 | | -#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O0 -ggdb") |
| 30 | +if(${FENIX_SYSTEM_INC_FIX}) |
| 31 | + include(cmake/systemMPIOverride.cmake) |
| 32 | +endif() |
31 | 33 |
|
32 | | -#ENABLE_TESTING |
33 | | -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}) |
34 | | -#include(testref/TestAgainstReference) |
35 | 34 |
|
36 | | -configure_file( |
37 | | - ${CMAKE_CURRENT_SOURCE_DIR}/include/fenix-config.h.in |
38 | | - ${CMAKE_CURRENT_BINARY_DIR}/include/fenix-config.h @ONLY |
39 | | -) |
| 35 | +add_subdirectory(src) |
40 | 36 |
|
41 | 37 |
|
42 | | -#Check for MPICC definition, if not try to find MPI |
43 | | -if(NOT "a$ENV{MPICC}" STREQUAL "a") |
44 | | - #set(CMAKE_C_COMPILER ${MPI_C_COMPILER} CACHE STRING "The compiler CMake should use - often set to mpicc" FORCE) |
45 | | - set(MPI_C_COMPILER $ENV{MPICC}) |
46 | | - set(CMAKE_C_COMPILER ${MPI_C_COMPILER}) |
47 | | - |
48 | | - message("[fenix] MPICC has been passed: $ENV{MPICC}") |
49 | | -else() |
50 | | - message("[fenix] MPICC was not passed, searching for MPI") |
51 | | - find_package(MPI REQUIRED) |
52 | | - if(${MPI_C_FOUND}) |
53 | | - message("[fenix] Found MPICC: ${MPI_C_COMPILER}") |
54 | | - else() |
55 | | - message( FATAL_ERROR "[fenix] MPI not found :( Aborting!") |
56 | | - endif() |
| 38 | +include(CTest) |
| 39 | +list(APPEND MPIEXEC_PREFLAGS "--with-ft;mpi") |
| 40 | + |
| 41 | +if(BUILD_EXAMPLES) |
| 42 | + add_subdirectory(examples) |
57 | 43 | endif() |
58 | 44 |
|
59 | | -#Helper function for linking with MPI only if needed |
60 | | -function(linkMPI TOLINK) |
61 | | - #We only want to try to find MPI outrselves if it wasn't provided in MPICC by user |
62 | | - if("a$ENV{MPICC}" STREQUAL "a") |
63 | | - #find_package(MPI REQUIRED) |
64 | | - target_link_libraries(${TOLINK} MPI::MPI_C) |
65 | | - endif() |
66 | | -endfunction(linkMPI) |
| 45 | +if(BUILD_TESTING) |
| 46 | + add_subdirectory(test) |
| 47 | +endif() |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | +configure_file( |
| 52 | + ${CMAKE_CURRENT_SOURCE_DIR}/include/fenix-config.h.in |
| 53 | + ${CMAKE_CURRENT_BINARY_DIR}/include/fenix-config.h @ONLY |
| 54 | +) |
| 55 | +configure_file( |
| 56 | + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/systemMPIOverride.cmake |
| 57 | + ${CMAKE_CURRENT_BINARY_DIR}/cmake/systemMPIOverride.cmake COPYONLY |
| 58 | +) |
67 | 59 |
|
68 | | -add_subdirectory(src) |
69 | 60 |
|
70 | 61 | include(CMakePackageConfigHelpers) |
71 | | -configure_package_config_file(fenixConfig.cmake.in |
72 | | - ${CMAKE_CURRENT_BINARY_DIR}/fenixConfig.cmake |
| 62 | +configure_package_config_file(cmake/fenixConfig.cmake.in |
| 63 | + ${CMAKE_CURRENT_BINARY_DIR}/cmake/fenixConfig.cmake |
73 | 64 | INSTALL_DESTINATION cmake) |
74 | | -write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/fenixConfigVersion.cmake |
| 65 | +write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/cmake/fenixConfigVersion.cmake |
75 | 66 | VERSION "${FENIX_VERSION_MAJOR}.${FENIX_VERSION_MINOR}" |
76 | 67 | COMPATIBILITY SameMajorVersion) |
77 | 68 | install( |
78 | 69 | FILES |
79 | | - ${CMAKE_CURRENT_BINARY_DIR}/fenixConfig.cmake |
80 | | - ${CMAKE_CURRENT_BINARY_DIR}/fenixConfigVersion.cmake |
| 70 | + ${CMAKE_CURRENT_BINARY_DIR}/cmake/fenixConfig.cmake |
| 71 | + ${CMAKE_CURRENT_BINARY_DIR}/cmake/systemMPIOverride.cmake |
81 | 72 | DESTINATION cmake |
82 | 73 | ) |
83 | | - |
84 | | - |
85 | | -include(CTest) |
86 | | - |
87 | | -if(BUILD_EXAMPLES) |
88 | | - add_subdirectory(examples/01_hello_world/fenix) |
89 | | - add_subdirectory(examples/01_hello_world/mpi) |
90 | | - add_subdirectory(examples/02_send_recv/fenix) |
91 | | - add_subdirectory(examples/02_send_recv/mpi) |
92 | | - add_subdirectory(examples/03_reduce/fenix) |
93 | | - #add_subdirectory(examples/03_reduce/mpi) |
94 | | - add_subdirectory(examples/04_Isend_Irecv/fenix) |
95 | | - add_subdirectory(examples/04_Isend_Irecv/mpi) |
96 | | - add_subdirectory(examples/05_subset_create) |
97 | | - add_subdirectory(examples/06_subset_createv) |
98 | | - |
99 | | -elseif(BUILD_TESTING) |
100 | | - #Some examples are useful tests as well. |
101 | | - add_subdirectory(examples/01_hello_world/fenix) |
102 | | - add_subdirectory(examples/02_send_recv/fenix) |
103 | | - add_subdirectory(examples/03_reduce/fenix) |
104 | | - add_subdirectory(examples/05_subset_create) |
105 | | - add_subdirectory(examples/06_subset_createv) |
106 | | -endif() |
107 | | - |
108 | | -if(BUILD_TESTING) |
109 | | - add_subdirectory(test/subset_internal) |
110 | | - add_subdirectory(test/subset_merging) |
111 | | - add_subdirectory(test/request_tracking) |
112 | | - add_subdirectory(test/request_cancelled) |
113 | | - add_subdirectory(test/no_jump) |
114 | | - add_subdirectory(test/issend) |
115 | | -endif() |
0 commit comments