Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix static build and test on Linux. #1292

Merged
merged 7 commits into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
13 changes: 2 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,38 @@ jobs:
os: windows-latest
bindings_python: ON
build_shared: OFF
unit_tests: ON
set_path: $env:Path="C:\libxml2\bin;C:\zlib\bin;"+$env:Path
additional_cmake_options: -DLIBXML2_INCLUDE_DIR="C:\libxml2\include\libxml2" -DLIBXML2_LIBRARY="C:\libxml2\lib\libxml2.lib" -DZLIB_INCLUDE_DIR="C:\zlib\include" -DZLIB_LIBRARY="C:\zlib\lib\z_dll.lib"
- name: 'Windows shared - C++/Python'
os: windows-latest
bindings_python: ON
build_shared: ON
unit_tests: ON
set_path: $env:Path="C:\libxml2\bin;C:\zlib\bin;"+$env:Path
additional_cmake_options: -DLIBXML2_INCLUDE_DIR="C:\libxml2\include\libxml2" -DLIBXML2_LIBRARY="C:\libxml2\lib\libxml2.lib" -DZLIB_INCLUDE_DIR="C:\zlib\include" -DZLIB_LIBRARY="C:\zlib\lib\z_dll.lib"
- name: 'Linux static - C++ (build only)'
- name: 'Linux static - C++'
os: ubuntu-latest
bindings_python: OFF
build_shared: OFF
unit_tests: OFF
- name: 'Linux shared - C++/Python'
os: ubuntu-latest
bindings_python: ON
build_shared: ON
unit_tests: ON
- name: 'macOS static - C++ (Intel)'
os: macos-13
bindings_python: OFF
build_shared: OFF
unit_tests: ON
- name: 'macOS shared - C++/Python (Intel)'
os: macos-13
bindings_python: ON
build_shared: ON
unit_tests: ON
- name: 'macOS static - C++ (ARM)'
os: macos-latest
bindings_python: OFF
build_shared: OFF
unit_tests: ON
- name: 'macOS shared - C++/Python (ARM)'
os: macos-latest
bindings_python: ON
build_shared: ON
unit_tests: ON
steps:
- name: Check out libCellML
uses: actions/checkout@v4
Expand Down Expand Up @@ -99,13 +91,12 @@ jobs:
mkdir build
cd build
${{ matrix.set_path }}
cmake -G Ninja -DBINDINGS_PYTHON=${{ matrix.bindings_python }} -DBUILD_SHARED=${{ matrix.build_shared }} -DCOVERAGE=OFF -DLLVM_COVERAGE=OFF -DMEMCHECK=OFF -DUNIT_TESTS=${{ matrix.unit_tests }} ${{ matrix.additional_cmake_options }} ..
cmake -G Ninja -DBINDINGS_PYTHON=${{ matrix.bindings_python }} -DBUILD_SHARED=${{ matrix.build_shared }} -DCOVERAGE=OFF -DLLVM_COVERAGE=OFF -DMEMCHECK=OFF -DUNIT_TESTS=ON ${{ matrix.additional_cmake_options }} ..
- name: Build libCellML
run: |
cd build
ninja
- name: Unit testing
if: ${{ matrix.unit_tests == 'ON' }}
run: |
cd build
ninja test
Expand Down
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.")
agarny marked this conversation as resolved.
Show resolved Hide resolved
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
Loading