Skip to content

Commit 0152690

Browse files
committed
Merge branch 'cmake-modernize'
2 parents 9f21ff1 + 5ee4cad commit 0152690

File tree

7 files changed

+86
-36
lines changed

7 files changed

+86
-36
lines changed

.travis.yml

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ os: osx
55

66
env:
77
global:
8+
# - ZERO_AR_DATE=1
9+
- TZ=UTC
810
- CACHE="${HOME}/.local"
911
- MPICH_VER="3.2.1"
1012
- MPICH_URL_HEAD="https://www.mpich.org/static/downloads/${MPICH_VER}"
@@ -102,6 +104,8 @@ install:
102104

103105
script:
104106
- pwd
107+
- export SOURCE_DATE_EPOCH=$(git show -s --format=%ct $TRAVIS_COMMIT)
108+
- echo "SOURCE_DATE_EPOCH = ${SOURCE_DATE_EPOCH}"
105109
- ./developer-scripts/travis/test-script.${BUILD_TYPE:-cmake}.sh
106110

107111
after_script:

CMakeLists.txt

+28-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
cmake_minimum_required(VERSION 3.10)
22

3-
cmake_policy(VERSION 3.10...3.12)
4-
3+
cmake_policy(VERSION 3.10...3.14)
4+
5+
set(CMAKE_SKIP_RPATH ON
6+
CACHE BOOL "Don't add a build-dir rpath")
7+
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON
8+
CACHE BOOL "Build using the install rpath")
9+
set(CMAKE_BUILD_RPATH_USE_ORIGIN ON
10+
CACHE BOOL "Use relative rpaths")
511
# Set the type/configuration of build to perform
612
set ( CMAKE_CONFIGURATION_TYPES "Debug" "Release" "MinSizeRel" "RelWithDebInfo" "CodeCoverage" )
713
set ( CMAKE_BUILD_TYPE "Release"
@@ -88,6 +94,11 @@ string(REGEX REPLACE "-rc[0-9]+$"
8894

8995
project(opencoarrays VERSION "${OPENCOARRAYS_CMAKE_PROJECT_VERSION}" LANGUAGES C Fortran)
9096

97+
if(DEFINED CMAKE_BUILD_TYPE AND "${CMAKE_BUILD_TYPE}" MATCHES "[Rr][Ee][Ll]")
98+
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-working-directory")
99+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-working-directory")
100+
endif()
101+
91102
message( STATUS "Building OpenCoarrays version: ${full_git_describe}" )
92103
set(OpenCoarrays_dist_string "OpenCoarrays-${full_git_describe}")
93104
message( STATUS "Building for target architecture: ${CMAKE_SYSTEM_PROCESSOR}" )
@@ -211,7 +222,7 @@ endif()
211222

212223
if(gfortran_compiler)
213224
set(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
214-
set(CMAKE_REQUIRED_FLAGS $<$<COMPILE_LANGUAGE:Fortran>:"-fcoarray=single -ffree-form">)
225+
set(CMAKE_REQUIRED_FLAGS $<$<COMPILE_LANGUAGE:Fortran>:-fcoarray=single -ffree-form>)
215226
endif()
216227
include(CheckFortranSourceCompiles)
217228
CHECK_Fortran_SOURCE_COMPILES("
@@ -483,7 +494,6 @@ set(CMAKE_C_COMPILE_FLAGS "${CMAKE_C_COMPILE_FLAGS} ${MPI_C_COMPILE_FLAGS}")
483494
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} ${MPI_C_LINK_FLAGS}")
484495
set(CMAKE_Fortran_COMPILE_FLAGS "${CMAKE_Fortran_COMPILE_FLAGS} ${MPI_Fortran_COMPILE_FLAGS}")
485496
set(CMAKE_Fortran_LINK_FLAGS "${CMAKE_Fortran_LINK_FLAGS} ${MPI_Fortran_LINK_FLAGS}")
486-
include_directories(BEFORE ${MPI_C_INCLUDE_PATH} ${MPI_Fortran_INCLUDE_PATH})
487497

488498
#---------------------------------------------------
489499
# Use standardized GNU install directory conventions
@@ -527,8 +537,9 @@ function(caf_compile_executable target main_depend)
527537
-o "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${target}"
528538
"${CMAKE_CURRENT_SOURCE_DIR}/${main_depend}"
529539
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libopencoarrays_test_utilities.a"
540+
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libopencoarrays_mod.a"
530541
${ARGN}
531-
DEPENDS "${main_depend}" ${ARGN} caf_mpi_static opencoarrays_test_utilities
542+
DEPENDS "${main_depend}" ${ARGN} caf_mpi_static opencoarrays_test_utilities opencoarrays_mod
532543
VERBATIM
533544
)
534545
add_custom_target("build_${target}" ALL
@@ -591,8 +602,6 @@ define_property(TARGET
591602
#-------------------------------
592603
# Recurse into the src directory
593604
#-------------------------------
594-
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/src)
595-
596605
add_subdirectory(src)
597606

598607
#-----------------------------------------------------
@@ -621,10 +630,6 @@ install(
621630
"${CMAKE_INSTALL_LIBDIR}/cmake/opencoarrays"
622631
)
623632

624-
add_library(OpenCoarrays INTERFACE)
625-
target_compile_options(OpenCoarrays INTERFACE $<$<COMPILE_LANGUAGE:Fortran>:"-fcoarray=lib")
626-
target_link_libraries(OpenCoarrays INTERFACE caf_mpi)
627-
628633
#------------------------------------------
629634
# Add portable unistall command to makefile
630635
#------------------------------------------
@@ -639,6 +644,14 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure)
639644
# See JSON-Fortran's CMakeLists.txt file to find out how to get the check target to depend
640645
# on the test executables
641646

647+
#------------------------------------
648+
# Add command to hash installed files
649+
#------------------------------------
650+
configure_file( "${CMAKE_SOURCE_DIR}/cmake/hash-installed.cmake.in" "${CMAKE_BINARY_DIR}/hash-installed.cmake"
651+
@ONLY)
652+
add_custom_target( hash_installed
653+
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_BINARY_DIR}/hash-installed.cmake")
654+
642655
#---------------------------------------------------------------------------------------
643656
# Define macro for adding CAF tests, and ensuring proper flags are passed to MPI runtime
644657
#---------------------------------------------------------------------------------------
@@ -916,3 +929,7 @@ foreach(SCRIPT ${TRAVIS_SCRIPTS})
916929
lint_script("${CMAKE_SOURCE_DIR}/developer-scripts/travis" ${SCRIPT})
917930
endif()
918931
endforeach()
932+
933+
install(FILES "${CMAKE_BINARY_DIR}/sha256_install_manifest.txt"
934+
DESTINATION "${CMAKE_INSTALL_DATADIR}/opencoarrays"
935+
OPTIONAL)

cmake/hash-installed.cmake.in

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
file(WRITE "@CMAKE_BINARY_DIR@/sha256_install_manifest.txt" "")
10+
foreach(file ${files})
11+
if(IS_SYMLINK $ENV{DESTDIR}${file})
12+
list(APPEND symbolic_links ${file})
13+
endif()
14+
file(SHA256 $ENV{DESTDIR}${file} ${file}_sha256)
15+
message(STATUS "${${file}_sha256} $ENV{DESTDIR}${file}")
16+
file(APPEND "@CMAKE_BINARY_DIR@/sha256_install_manifest.txt" "${${file}_sha256} $ENV{DESTDIR}${file}\n")
17+
endforeach()
18+
message(STATUS "Symbolic links: ${symbolic_links}")

cmake/uninstall.cmake.in

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ endif(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
66

77
file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
88
string(REGEX REPLACE "\n" ";" files "${files}")
9+
foreach(file ${files})
10+
if(NOT IS_SYMLINK $ENV{DESTDIR}${file})
11+
file(SHA256 $ENV{DESTDIR}${file} ${file}_sha256)
12+
message(STATUS "${${file}_sha256} $ENV{DESTDIR}${file}")
13+
else()
14+
message(STATUS "$ENV{DESTDIR}${file} is a symbolic link.")
15+
endif()
16+
endforeach()
917
foreach(file ${files})
1018
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
1119
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")

developer-scripts/travis/test-script.cmake.sh

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ for version in ${GCC}; do
6868
ctest "${CTEST_FLAGS[@]}"
6969
fi
7070
make install
71+
make hash_installed
72+
make install
7173
make uninstall
7274
)
7375
done

src/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ if(openmpi)
1313
set(openmpi ${openmpi} PARENT_SCOPE)
1414
endif()
1515

16-
install( FILES libcaf.h libcaf-gfortran-descriptor.h
16+
install( FILES libcaf.h libcaf-gfortran-descriptor.h libcaf-version-def.h
1717
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
1818
)

src/mpi/CMakeLists.txt

+25-24
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,32 @@ target_compile_options(opencoarrays_mod
2626
target_link_libraries(opencoarrays_mod
2727
PUBLIC ${MPI_Fortran_LINK_FLAGS}
2828
PUBLIC ${MPI_Fortran_LIBRARIES})
29-
target_include_directories(opencoarrays_mod
30-
PRIVATE $<$<COMPILE_LANGUAGE:Fortran>:${MPI_Fortran_INCLUDE_PATH}>)
29+
target_link_libraries(opencoarrays_mod
30+
PUBLIC caf_mpi_static)
31+
target_include_directories(opencoarrays_mod PUBLIC
32+
$<$<COMPILE_LANGUAGE:Fortran>:${MPI_Fortran_INCLUDE_PATH}>
33+
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/${mod_dir_tail}>
34+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${mod_dir_tail}>)
3135

3236
add_library(caf_mpi SHARED mpi_caf.c ../common/caf_auxiliary.c)
3337
add_library(caf_mpi_static STATIC mpi_caf.c ../common/caf_auxiliary.c)
3438
target_link_libraries(caf_mpi
3539
PUBLIC ${MPI_C_LINK_FLAGS}
36-
PUBLIC ${MPI_C_LIBRARIES}
37-
PRIVATE opencoarrays_mod)
40+
PUBLIC ${MPI_C_LIBRARIES})
3841
target_link_libraries(caf_mpi_static
3942
PUBLIC ${MPI_C_LINK_FLAGS}
40-
PUBLIC ${MPI_C_LIBRARIES}
41-
PRIVATE opencoarrays_mod)
43+
PUBLIC ${MPI_C_LIBRARIES})
4244
set_target_properties(caf_mpi_static
4345
PROPERTIES
4446
POSITION_INDEPENDENT_CODE TRUE)
45-
target_include_directories(caf_mpi
46-
PUBLIC $<$<COMPILE_LANGUAGE:C>:${MPI_C_INCLUDE_PATH}>)
47-
target_include_directories(caf_mpi_static
48-
PUBLIC $<$<COMPILE_LANGUAGE:C>:${MPI_C_INCLUDE_PATH}>)
47+
target_include_directories(caf_mpi PUBLIC
48+
$<$<COMPILE_LANGUAGE:C>:${MPI_C_INCLUDE_PATH}>
49+
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src>
50+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
51+
target_include_directories(caf_mpi_static PUBLIC
52+
$<$<COMPILE_LANGUAGE:C>:${MPI_C_INCLUDE_PATH}>
53+
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src>
54+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
4955
target_compile_options(caf_mpi
5056
PUBLIC $<$<COMPILE_LANGUAGE:C>:${MPI_C_COMPILE_FLAGS}>)
5157
target_compile_options(caf_mpi_static
@@ -77,7 +83,7 @@ if(UNIX)
7783
endif()
7884

7985
install(DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}/" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
80-
FILES_MATCHING PATTERN "*.mod")
86+
FILES_MATCHING PATTERN "opencoarrays.mod")
8187

8288
set_target_properties( caf_mpi_static
8389
PROPERTIES
@@ -86,22 +92,15 @@ set_target_properties( caf_mpi_static
8692
)
8793

8894
if (gfortran_compiler)
89-
target_compile_options(caf_mpi INTERFACE $<$<COMPILE_LANGUAGE:Fortran>:"-fcoarray=lib">)
90-
target_compile_options(caf_mpi_static INTERFACE $<$<COMPILE_LANGUAGE:Fortran>:"-fcoarray=lib">)
95+
target_compile_options(caf_mpi INTERFACE $<$<COMPILE_LANGUAGE:Fortran>:-fcoarray=lib>)
96+
target_compile_options(caf_mpi_static INTERFACE $<$<COMPILE_LANGUAGE:Fortran>:-fcoarray=lib>)
9197
endif()
9298

93-
install(TARGETS opencoarrays_mod EXPORT OpenCoarraysTargets
94-
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
95-
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
96-
)
97-
install(TARGETS caf_mpi EXPORT OpenCoarraysTargets
99+
install(TARGETS opencoarrays_mod caf_mpi caf_mpi_static EXPORT OpenCoarraysTargets
98100
DESTINATION "${CMAKE_INSTALL_LIBDIR}"
99-
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
100-
)
101-
install(TARGETS caf_mpi_static EXPORT OpenCoarraysTargets
102101
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
103102
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
104-
)
103+
)
105104

106105
#----------------------------------
107106
# Determine if we're using Open MPI
@@ -128,12 +127,14 @@ elseif("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "PGI")
128127
endif()
129128

130129
if(gfortran_compiler AND (NOT opencoarrays_aware_compiler))
131-
target_compile_definitions(opencoarrays_mod PUBLIC -DCOMPILER_SUPPORTS_CAF_INTRINSICS)
130+
target_compile_definitions(opencoarrays_mod
131+
PUBLIC -DCOMPILER_SUPPORTS_CAF_INTRINSICS)
132132
endif()
133133

134134
option(CAF_EXPOSE_INIT_FINALIZE "Expose caf_init and caf_finalize in opencoarrays module" FALSE)
135135
if(CAF_EXPOSE_INIT_FINALIZE)
136-
target_compile_definitions(opencoarrays_mod PRIVATE -DEXPOSE_INIT_FINALIZE)
136+
target_compile_definitions(opencoarrays_mod
137+
PRIVATE -DEXPOSE_INIT_FINALIZE)
137138
endif()
138139

139140
include(CheckIncludeFile)

0 commit comments

Comments
 (0)