Skip to content

Commit

Permalink
CMakeListst.txt cleanup and changelog entry
Browse files Browse the repository at this point in the history
  • Loading branch information
billschereriii committed Jul 27, 2023
1 parent 67de648 commit ffa907d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 24 deletions.
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,16 @@ if (STATIC_BUILD)
target_link_libraries(smartredis PUBLIC ${EXT_CLIENT_LIBRARIES} PRIVATE Threads::Threads)

# Merge SmartRedis static library with dependencies
# . Create a sacrificial dummy file so we have source to make a target against
set(DUMMY_FILE ${CMAKE_BINARY_DIR}/merge-dummy.cpp)
file(
WRITE ${DUMMY_FILE}
"// Life, the universe, and everything!\nstatic int sr_magic_number = 42;\n"
)
add_library(${SMARTREDIS_LIB} STATIC ${DUMMY_FILE})
set(STATIC_LIB_COMPONENTS ${SR_LIB_INSTALL_PATH}/${TEMP_LIB_FULLNAME} ${EXT_CLIENT_LIBRARIES})

# . Archive the static libraries together into a thin library
add_custom_command(
TARGET smartredis
POST_BUILD
Expand All @@ -157,8 +160,7 @@ if (STATIC_BUILD)
# Install static library
install(TARGETS ${SMARTREDIS_LIB}
LIBRARY DESTINATION lib)

else ()
else () # Shared library build
add_library(smartredis ${SMARTREDIS_LINK_MODE} ${CLIENT_SRC})
set_target_properties(smartredis PROPERTIES
SUFFIX ${SMARTREDIS_LINK_LIBRARY_SUFFIX}
Expand Down
3 changes: 3 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ To be released at some future point in time

Description

- Enable static builds of SmartRedis
- Improve robustness of test runs
- Fix installation link
- Update supported languages documentation
Expand All @@ -17,6 +18,7 @@ Description

Detailed Notes

- Static builds of SmartRedis can now work with Linux platforms. Fortran is only tested with GNU and Intel compilers (PR386_)
- Preserve the shell output of test runs while making sure that server shutdown happens unconditionally (PR381_)
- Fix incorrect link to installation documentation (PR380_)
- Update language support matrix in documentation to reflect updates from the last release (PR379_)
Expand All @@ -25,6 +27,7 @@ Detailed Notes
- Deleted obsolete build and testing files that are no longer needed with the new build and test system (PR366_)
- Reuse existing redis connection when mapping the Redis cluster (PR364_)

.. _PR386: https://github.com/CrayLabs/SmartRedis/pull/386
.. _PR381: https://github.com/CrayLabs/SmartRedis/pull/381
.. _PR380: https://github.com/CrayLabs/SmartRedis/pull/380
.. _PR379: https://github.com/CrayLabs/SmartRedis/pull/379
Expand Down
15 changes: 9 additions & 6 deletions examples/parallel/fortran/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,25 @@ set_target_properties(smartredis-fortran PROPERTIES

# Extras for static builds
if (STATIC_BUILD)
if (CMAKE_Fortran_COMPILER_ID MATCHES "^Intel")
# For Intel, don't set languages so that CMake will use the Fortran linker (default)

# Add the stdc++ linker flag
set(CMAKE_EXE_LINKER_FLAGS "-lstdc++ ${CMAKE_EXE_LINKER_FLAGS}")
else() # Solution tested with GNU
# The CMake "preferred" approach only seems to work with the GNU
# compiler. We will streamline this in the future
if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
# Mark that SmartRedis requires the C++ linker
set_target_properties(smartredis-main PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
)
set_target_properties(smartredis-fortran PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "FORTRAN"
)
else() # Tested with PGI, Intel
# For other compilers, don't set languages so that CMake will use the Fortran linker (default)

# Add the stdc++ linker flag
set(CMAKE_EXE_LINKER_FLAGS "-lstdc++ ${CMAKE_EXE_LINKER_FLAGS}")
endif()

# Static builds have an extra dependency on the Pthreads library
# The order of libraries here is crucial to get dependencies covered
find_package(Threads REQUIRED)
set(SMARTREDIS_LIBRARIES
smartredis-fortran
Expand Down
26 changes: 13 additions & 13 deletions examples/serial/fortran/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ if(NOT DEFINED SMARTREDIS_INSTALL_PATH)
endif()

# Locate dependencies
# . Main SmartRedis Library (C++ based)
add_library(smartredis-main ${SMARTREDIS_LINK_MODE} IMPORTED)
find_library(SR_LIB ${SMARTREDIS_LIB}
PATHS ${SMARTREDIS_INSTALL_PATH}/lib NO_DEFAULT_PATH
Expand All @@ -54,15 +55,11 @@ find_library(SR_LIB ${SMARTREDIS_LIB}
set_target_properties(smartredis-main PROPERTIES
IMPORTED_LOCATION ${SR_LIB}
)
#find_library(SR_LIB ${SMARTREDIS_LIB}
# PATHS ${SMARTREDIS_INSTALL_PATH}/lib NO_DEFAULT_PATH
# REQUIRED
# ${SMARTREDIS_LINK_MODE}
#)
# . SmartRedis Fortran Library (C++ based)
add_library(smartredis-fortran ${SMARTREDIS_LINK_MODE} IMPORTED)
find_library(SR_FTN_LIB ${SMARTREDIS_FORTRAN_LIB}
PATHS ${SMARTREDIS_INSTALL_PATH}/lib NO_DEFAULT_PATH
REQUIRED
PATHS ${SMARTREDIS_INSTALL_PATH}/lib NO_DEFAULT_PATH
REQUIRED
${SMARTREDIS_LINK_MODE}
)
set_target_properties(smartredis-fortran PROPERTIES
Expand All @@ -71,22 +68,25 @@ set_target_properties(smartredis-fortran PROPERTIES

# Extras for static builds
if (STATIC_BUILD)
if (CMAKE_Fortran_COMPILER_ID MATCHES "^Intel")
# For Intel, don't set languages so that CMake will use the Fortran linker (default)

# Add the stdc++ linker flag
set(CMAKE_EXE_LINKER_FLAGS "-lstdc++ ${CMAKE_EXE_LINKER_FLAGS}")
else() # Solution tested with GNU
# The CMake "preferred" approach only seems to work with the GNU
# compiler. We will streamline this in the future
if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
# Mark that SmartRedis requires the C++ linker
set_target_properties(smartredis-main PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
)
set_target_properties(smartredis-fortran PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "FORTRAN"
)
else() # Tested with PGI, Intel
# For other compilers, don't set languages so that CMake will use the Fortran linker (default)

# Add the stdc++ linker flag
set(CMAKE_EXE_LINKER_FLAGS "-lstdc++ ${CMAKE_EXE_LINKER_FLAGS}")
endif()

# Static builds have an extra dependency on the Pthreads library
# The order of libraries here is crucial to get dependencies covered
find_package(Threads REQUIRED)
set(SMARTREDIS_LIBRARIES
smartredis-fortran
Expand Down
6 changes: 3 additions & 3 deletions smartredis_defs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ if(srlink_lowercase STREQUAL "static")
set(SMARTREDIS_LINK_SUFFIX "-static")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(STATIC_BUILD TRUE)
# if(APPLE)
# message(FATAL_ERROR "Static builds are not supported on MacOS")
# endif(APPLE)
if(APPLE)
message(FATAL_ERROR "Static builds are not supported on MacOS")
endif(APPLE)
elseif(srlink_lowercase STREQUAL "shared")
set(SMARTREDIS_LINK_MODE SHARED)
set(SMARTREDIS_LINK_LIBRARY_SUFFIX .so)
Expand Down

0 comments on commit ffa907d

Please sign in to comment.