Skip to content

Fix linking issue with shared libraries #642

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion config/DefaultFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
CMAKE_Fortran_FLAGS_INIT
"-fimplicit-none"
"-ffree-line-length-132"
"-fno-range-check"
)
set(
CMAKE_Fortran_FLAGS_RELEASE_INIT
Expand Down
8 changes: 8 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ set(SRC

add_library(${PROJECT_NAME} ${SRC})

if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU AND CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 10.0)
target_compile_options(
${PROJECT_NAME}
PRIVATE
$<$<COMPILE_LANGUAGE:Fortran>:-fno-range-check>
)
endif()

set(LIB_MOD_DIR ${CMAKE_CURRENT_BINARY_DIR}/mod_files/)
# We need the module directory before we finish the configure stage since the
# build interface might resolve before the module directory is generated by CMake
Expand Down
41 changes: 21 additions & 20 deletions src/tests/hash_functions/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
#ADDTEST(hash_functions)

set(SRC
nmhash_scalar.c
pengyhash.c
SpookyV2.cpp
SpookyV2Test.cpp
waterhash.c
generate_hash_arrays.cpp
)

enable_language(CXX)
enable_language(C)

add_library(libc_hash ${SRC})

set(CMAKE_FORTRAN_LINK_EXECUTABLE "<CMAKE_Fortran_COMPILER> <CMAKE_Fortran_LINK_FLAGS> <LINK_FLAGS> <FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")

add_executable(test_hash_functions test_hash_functions.f90)
target_link_libraries(test_hash_functions "${PROJECT_NAME}" "test-drive::test-drive" "libc_hash")
add_test(NAME hash_functions
COMMAND $<TARGET_FILE:test_hash_functions> ${CMAKE_CURRENT_BINARY_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

set_target_properties(test_hash_functions PROPERTIES LINKER_LANGUAGE FORTRAN)
ADDTEST(hash_functions)
target_sources(
test_hash_functions
PRIVATE
nmhash_scalar.c
pengyhash.c
SpookyV2.cpp
SpookyV2Test.cpp
waterhash.c
generate_hash_arrays.cpp
)
if(CMAKE_Fortran_COMPILER_ID MATCHES "^Intel")
set_target_properties(test_hash_functions PROPERTIES LINKER_LANGUAGE Fortran)
endif()
if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU AND CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 10.0)
target_compile_options(
test_hash_functions
PRIVATE
$<$<COMPILE_LANGUAGE:Fortran>:-fno-range-check>
)
endif()
8 changes: 8 additions & 0 deletions src/tests/hash_functions_perf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
ADDTEST(32_bit_hash_performance)
ADDTEST(64_bit_hash_performance)

if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU AND CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 10.0)
target_compile_options(
test_64_bit_hash_performance
PRIVATE
$<$<COMPILE_LANGUAGE:Fortran>:-fno-range-check>
)
endif()