Skip to content

Commit 8eaa778

Browse files
authored
Merge pull request #642 from awvwgk/cmake
Fix linking issue with shared libraries
2 parents ee4d105 + 0f88076 commit 8eaa778

File tree

4 files changed

+37
-21
lines changed

4 files changed

+37
-21
lines changed

config/DefaultFlags.cmake

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
33
CMAKE_Fortran_FLAGS_INIT
44
"-fimplicit-none"
55
"-ffree-line-length-132"
6-
"-fno-range-check"
76
)
87
set(
98
CMAKE_Fortran_FLAGS_RELEASE_INIT

src/CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ set(SRC
9494

9595
add_library(${PROJECT_NAME} ${SRC})
9696

97+
if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU AND CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 10.0)
98+
target_compile_options(
99+
${PROJECT_NAME}
100+
PRIVATE
101+
$<$<COMPILE_LANGUAGE:Fortran>:-fno-range-check>
102+
)
103+
endif()
104+
97105
set(LIB_MOD_DIR ${CMAKE_CURRENT_BINARY_DIR}/mod_files/)
98106
# We need the module directory before we finish the configure stage since the
99107
# build interface might resolve before the module directory is generated by CMake
+21-20
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
#ADDTEST(hash_functions)
22

3-
set(SRC
4-
nmhash_scalar.c
5-
pengyhash.c
6-
SpookyV2.cpp
7-
SpookyV2Test.cpp
8-
waterhash.c
9-
generate_hash_arrays.cpp
10-
)
11-
123
enable_language(CXX)
134
enable_language(C)
145

15-
add_library(libc_hash ${SRC})
16-
17-
set(CMAKE_FORTRAN_LINK_EXECUTABLE "<CMAKE_Fortran_COMPILER> <CMAKE_Fortran_LINK_FLAGS> <LINK_FLAGS> <FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
18-
19-
add_executable(test_hash_functions test_hash_functions.f90)
20-
target_link_libraries(test_hash_functions "${PROJECT_NAME}" "test-drive::test-drive" "libc_hash")
21-
add_test(NAME hash_functions
22-
COMMAND $<TARGET_FILE:test_hash_functions> ${CMAKE_CURRENT_BINARY_DIR}
23-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
24-
25-
set_target_properties(test_hash_functions PROPERTIES LINKER_LANGUAGE FORTRAN)
6+
ADDTEST(hash_functions)
7+
target_sources(
8+
test_hash_functions
9+
PRIVATE
10+
nmhash_scalar.c
11+
pengyhash.c
12+
SpookyV2.cpp
13+
SpookyV2Test.cpp
14+
waterhash.c
15+
generate_hash_arrays.cpp
16+
)
17+
if(CMAKE_Fortran_COMPILER_ID MATCHES "^Intel")
18+
set_target_properties(test_hash_functions PROPERTIES LINKER_LANGUAGE Fortran)
19+
endif()
20+
if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU AND CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 10.0)
21+
target_compile_options(
22+
test_hash_functions
23+
PRIVATE
24+
$<$<COMPILE_LANGUAGE:Fortran>:-fno-range-check>
25+
)
26+
endif()
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
ADDTEST(32_bit_hash_performance)
22
ADDTEST(64_bit_hash_performance)
3+
4+
if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU AND CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 10.0)
5+
target_compile_options(
6+
test_64_bit_hash_performance
7+
PRIVATE
8+
$<$<COMPILE_LANGUAGE:Fortran>:-fno-range-check>
9+
)
10+
endif()

0 commit comments

Comments
 (0)