Skip to content

Commit b281a23

Browse files
committed
Merge pull request #138 from sourceryinstitute/CMake-cleanup-#58
CMake cleanup, issue #58 Resolves #58 Some tweaks remain to be made to the build system
2 parents f58e204 + aeef9db commit b281a23

File tree

7 files changed

+57
-192
lines changed

7 files changed

+57
-192
lines changed

CMakeLists.txt

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,38 +87,47 @@ else()
8787
endif()
8888
endif()
8989

90-
91-
include(CheckFortranSourceCompiles.cmake)
90+
if(gfortran_compiler)
91+
set(CMAKE_REQUIRED_FLAGS "-fcoarray=single")
92+
endif()
93+
include(CheckFortranSourceCompiles)
9294
CHECK_Fortran_SOURCE_COMPILES("
9395
program main
9496
implicit none
9597
integer :: i
9698
i = this_image()
9799
end program
98100
" Check_Simple_Coarray_Fortran_Source_Compiles)
101+
if(gfortran_compiler)
102+
unset(CMAKE_REQUIRED_FLAGS)
103+
endif()
99104

100105
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
101106

102107
add_subdirectory(src)
103108
add_subdirectory(install_prerequisites)
104109

110+
#-----------------------------------------------------
111+
# Publicize installed location to other CMake projects
112+
#-----------------------------------------------------
105113
install(EXPORT OpenCoarraysTargets
106114
NAMESPACE
107115
OpenCoarrays::
108116
DESTINATION
109117
lib/cmake/opencoarrays
110118
)
111-
include(CMakePackageConfigHelpers)
119+
include(CMakePackageConfigHelpers) # standard CMake module
112120
write_basic_package_version_file(
113121
"${CMAKE_CURRENT_BINARY_DIR}/OpenCoarraysConfigVersion.cmake"
114-
VERSION 1.0
122+
VERSION "${opencoarrays_VERSION}"
115123
COMPATIBILITY AnyNewerVersion
116124
)
117-
configure_file(OpenCoarraysConfig.cmake.in CMakeFiles/OpenCoarraysConfig.cmake @ONLY)
125+
configure_file("${CMAKE_SOURCE_DIR}/cmake/pkg/OpenCoarraysConfig.cmake.in"
126+
"${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/OpenCoarraysConfig.cmake" @ONLY)
118127

119128
install(
120129
FILES
121-
${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/OpenCoarraysConfig.cmake
130+
"${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/OpenCoarraysConfig.cmake"
122131
"${CMAKE_CURRENT_BINARY_DIR}/OpenCoarraysConfigVersion.cmake"
123132
DESTINATION
124133
lib/cmake/opencoarrays
@@ -130,6 +139,17 @@ target_link_libraries(OpenCoarrays INTERFACE caf_mpi)
130139

131140
install(DIRECTORY ${CMAKE_BINARY_DIR}/mod DESTINATION .)
132141

142+
#------------------------------------------
143+
# Add portable unistall command to makefile
144+
#------------------------------------------
145+
# Adapted from the CMake Wiki FAQ
146+
configure_file ( "${CMAKE_SOURCE_DIR}/cmake/uninstall.cmake.in" "${CMAKE_BINARY_DIR}/uninstall.cmake"
147+
@ONLY)
148+
149+
add_custom_target ( uninstall
150+
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_BINARY_DIR}/uninstall.cmake" )
151+
152+
133153
enable_testing()
134154

135155
function(add_mpi_test name num_mpi_proc path)
@@ -169,15 +189,10 @@ if(opencoarrays_aware_compiler)
169189
add_mpi_test(hello_multiverse 2 ${tests_root}/integration/coarrayHelloWorld/hello_multiverse)
170190
add_mpi_test(coarray_burgers_pde 2 ${tests_root}/integration/pde_solvers/coarrayBurgers/coarray_burgers_pde)
171191
add_mpi_test(co_heat 2 ${tests_root}/integration/pde_solvers/coarrayHeatSimplified/co_heat)
172-
173-
execute_process (COMMAND uname -m
174-
OUTPUT_VARIABLE MACHINE_TYPE)
175-
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux" )
176-
if ("${MACHINE_TYPE}" MATCHES "x86_64")
177-
if ( NOT (DEFINED ENV{TRAVIS}))
178-
add_mpi_test(coarray_navier_stokes 2 ${tests_root}/integration/pde_solvers/navier-stokes/coarray_navier_stokes)
179-
set_property(TEST coarray_navier_stokes PROPERTY PASS_REGULAR_EXPRESSION "Test passed.")
180-
endif()
192+
if ( ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64") AND ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") )
193+
if ( NOT (DEFINED ENV{TRAVIS}))
194+
add_mpi_test(coarray_navier_stokes 2 ${tests_root}/integration/pde_solvers/navier-stokes/coarray_navier_stokes)
195+
set_property(TEST coarray_navier_stokes PROPERTY PASS_REGULAR_EXPRESSION "Test passed.")
181196
endif()
182197
endif()
183198
else()

CheckFortranSourceCompiles.cmake

Lines changed: 0 additions & 137 deletions
This file was deleted.
File renamed without changes.

cmake/uninstall.cmake.in

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Adapted from http://www.cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F May 1, 2014
2+
3+
if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
4+
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
5+
endif(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
6+
7+
file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
8+
string(REGEX REPLACE "\n" ";" files "${files}")
9+
foreach(file ${files})
10+
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
11+
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
12+
exec_program(
13+
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
14+
OUTPUT_VARIABLE rm_out
15+
RETURN_VALUE rm_retval
16+
)
17+
if(NOT "${rm_retval}" STREQUAL 0)
18+
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
19+
endif(NOT "${rm_retval}" STREQUAL 0)
20+
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
21+
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
22+
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
23+
endforeach(file)

src/mpi/CMakeLists.txt

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,6 @@ elseif("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "PGI")
1010
set(portland_group_compiler true)
1111
endif()
1212

13-
if (NOT CMAKE_VERSION VERSION_LESS 3.3.1)
14-
# Detect Fortran compiler version directly
15-
if(gfortran_compiler AND (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 5))
16-
set(opencoarrays_aware_compiler true)
17-
else()
18-
set(opencoarrays_aware_compiler false)
19-
endif()
20-
else()
21-
# Use the C compiler version as a proxy for the Fortran compiler version (won't work with NAG)
22-
if(gfortran_compiler AND (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5))
23-
set(opencoarrays_aware_compiler true)
24-
else()
25-
set(opencoarrays_aware_compiler false)
26-
endif()
27-
endif()
28-
2913
if(gfortran_compiler AND (NOT opencoarrays_aware_compiler))
3014
# This applied to gfortran 4.9 and some earlier versions (FIX ME: find out which)
3115
add_definitions(-DCOMPILER_SUPPORTS_CAF_INTRINSICS)
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
2-
execute_process (COMMAND uname -m
3-
OUTPUT_VARIABLE MACHINE_TYPE)
4-
# checking whether the machine is of type 64-bit before proceeding further
5-
if ("${MACHINE_TYPE}" MATCHES "x86_64")
6-
# Default to older SSE-instruction-based FFT library
7-
if (NOT (DEFINED ENV{TRAVIS}))
1+
# checking whether the machine is of type 64-bit before proceeding further
2+
if ( ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64") AND ("${CMAKE_SYSTEM_NAME}" MATCHES "LINUX") )
3+
# Default to older SSE-instruction-based FFT library
4+
if (NOT (DEFINED ENV{TRAVIS}))
85
if (LEGACY_ARCHITECTURE OR (NOT DEFINED(LEGACY_ARCHITECTURE)))
96
set(fft_library ${CMAKE_CURRENT_SOURCE_DIR}/libfft_sse.a )
107
else()
@@ -17,7 +14,6 @@ if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
1714
)
1815
target_link_libraries(coarray_navier_stokes OpenCoarrays ${fft_library})
1916
endif()
20-
endif()
2117
else()
2218
# Skip Navier-Stokes build until an appropriate FFT has been found.
2319
endif()

src/tests/unit/extensions/CMakeLists.txt

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,6 @@ if("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU")
22
set(gfortran_compiler true)
33
endif()
44

5-
if (NOT CMAKE_VERSION VERSION_LESS 3.3.1)
6-
# Detect Fortran compiler version directly
7-
if(gfortran_compiler AND (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 5.1))
8-
set(opencoarrays_aware_compiler true)
9-
else()
10-
set(opencoarrays_aware_compiler false)
11-
endif()
12-
else()
13-
# Use the C compiler version as a proxy for the Fortran compiler version (won't work with NAG)
14-
if(gfortran_compiler AND (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.1))
15-
set(opencoarrays_aware_compiler true)
16-
else()
17-
set(opencoarrays_aware_compiler false)
18-
endif()
19-
endif()
20-
215
if("${gfortran_compiler}" AND (NOT "${opencoarrays_aware_compiler}"))
226
# This applied to gfortran 4.9 and some earlier versions (TODO: find out which)
237
add_definitions(-DCOMPILER_SUPPORTS_CAF_INTRINSICS)

0 commit comments

Comments
 (0)