diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b7abf4e9f6..9b0b6920c9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -74,7 +66,7 @@ jobs: - name: Install CMake and Ninja uses: lukka/get-cmake@latest - name: Install buildcache - uses: mikehardy/buildcache-action@v2 + uses: cscouto/buildcache-action@v1 with: cache_key: ${{ matrix.os }}-${{ matrix.build_shared }} - name: Configure MSVC (Windows only) @@ -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 @@ -124,7 +115,7 @@ jobs: - name: Install CMake and Ninja uses: lukka/get-cmake@latest - name: Install buildcache - uses: mikehardy/buildcache-action@v2 + uses: cscouto/buildcache-action@v1 - name: Install Emscripten run: | brew install --overwrite emscripten @@ -193,7 +184,7 @@ jobs: - name: Install CMake and Ninja uses: lukka/get-cmake@latest - name: Install buildcache - uses: mikehardy/buildcache-action@v2 + uses: cscouto/buildcache-action@v1 - name: Install LLVM run: | brew install --overwrite llvm @@ -219,7 +210,7 @@ jobs: - name: Install CMake and Ninja uses: lukka/get-cmake@latest - name: Install buildcache - uses: mikehardy/buildcache-action@v2 + uses: cscouto/buildcache-action@v1 - name: Install Valgrind run: | sudo apt update @@ -244,7 +235,7 @@ jobs: - name: Install CMake and Ninja uses: lukka/get-cmake@latest - name: Install buildcache - uses: mikehardy/buildcache-action@v2 + uses: cscouto/buildcache-action@v1 - name: Install Doxygen run: | sudo apt update diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b790b2198f..e89a672648 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 ) diff --git a/src/analyserequationast.cpp b/src/analyserequationast.cpp index f543f766f1..ccb0a915a6 100644 --- a/src/analyserequationast.cpp +++ b/src/analyserequationast.cpp @@ -18,8 +18,6 @@ limitations under the License. #include "analyserequationast_p.h" -#include "libcellml/undefines.h" - namespace libcellml { void AnalyserEquationAst::AnalyserEquationAstImpl::populate(AnalyserEquationAst::Type type, diff --git a/src/bindings/CMakeLists.txt b/src/bindings/CMakeLists.txt index e981babe02..ded2e1d548 100644 --- a/src/bindings/CMakeLists.txt +++ b/src/bindings/CMakeLists.txt @@ -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 "It is **not** recommended to build the Python bindings with static libraries.") + endif() add_subdirectory(python) endif() diff --git a/src/bindings/interface/analyserequationast.i b/src/bindings/interface/analyserequationast.i index 3d064c706f..d8d42695f6 100644 --- a/src/bindings/interface/analyserequationast.i +++ b/src/bindings/interface/analyserequationast.i @@ -53,6 +53,9 @@ "Swaps the left and right children of this :class:`AnalyserEquationAst` object."; %{ +#include +#include + #include "libcellml/analyserequationast.h" %} diff --git a/src/bindings/python/CMakeLists.txt b/src/bindings/python/CMakeLists.txt index c98abd754f..966dc02647 100644 --- a/src/bindings/python/CMakeLists.txt +++ b/src/bindings/python/CMakeLists.txt @@ -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=$) -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=$) set(_GENERATOR_EXPRESSION_LIBCELLML_SONAME $) diff --git a/tests/gtest/cmake/internal_utils.cmake b/tests/gtest/cmake/internal_utils.cmake index 78ab035dff..d73dc4a995 100644 --- a/tests/gtest/cmake/internal_utils.cmake +++ b/tests/gtest/cmake/internal_utils.cmake @@ -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}