Skip to content

Commit

Permalink
Fix static build and test on Linux.
Browse files Browse the repository at this point in the history
  • Loading branch information
hsorby committed Nov 7, 2024
1 parent fa756b4 commit a016625
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ set_target_properties(cellml PROPERTIES
COMPATIBLE_INTERFACE_STRING ${PROJECT_VERSION_MAJOR}
)

if(NOT LIBCELLML_BUILD_SHARED AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
set_target_properties(cellml PROPERTIES POSITION_INDEPENDENT_CODE 1)
endif()

set(DEBUG_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/debug.cpp
)
Expand Down
3 changes: 3 additions & 0 deletions src/bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ if(LIBCELLML_BINDINGS_PYTHON) # Or any other bindings that use SWIG.
endif()

if(LIBCELLML_BINDINGS_PYTHON)
if(NOT LIBCELLML_BUILD_SHARED)
message(WARNING "The Python bindings are not intended to work with static libraries.")
endif()
add_subdirectory(python)
endif()

Expand Down
2 changes: 1 addition & 1 deletion src/bindings/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ set_source_files_properties(${SWIG_INTERFACE_SRCS} PROPERTIES

set(SETUP_PY_PACKAGE_FILES "'\${TARGET_FILE_NAME_cellml}'")
list(APPEND FINALISE_PYTHON_BINDINGS_ARGUMENTS -DTARGET_FILE_NAME_cellml=$<TARGET_FILE_NAME:cellml>)
if (UNIX AND NOT APPLE)
if (UNIX AND NOT APPLE AND LIBCELLML_BUILD_SHARED)
list(APPEND SETUP_PY_PACKAGE_FILES "'\${TARGET_SONAME_FILE_NAME_cellml}'")
list(APPEND FINALISE_PYTHON_BINDINGS_ARGUMENTS -DTARGET_SONAME_FILE_NAME_cellml=$<TARGET_SONAME_FILE_NAME:cellml>)
set(_GENERATOR_EXPRESSION_LIBCELLML_SONAME $<TARGET_SONAME_FILE:cellml>)
Expand Down
1 change: 1 addition & 0 deletions tests/gtest/cmake/internal_utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ function(cxx_library_with_type name type cxx_flags)
add_library(${name} ${type} ${ARGN})
set_target_properties(${name}
PROPERTIES
POSITION_INDEPENDENT_CODE 1
COMPILE_FLAGS "${cxx_flags}")
if (BUILD_SHARED_LIBS OR type STREQUAL "SHARED")
set_target_properties(${name}
Expand Down

0 comments on commit a016625

Please sign in to comment.