Skip to content

Commit 3a6abc4

Browse files
authored
Fixed an issue with creating a libOpenCOR-based application on Windows and macOS.
Also fixed a cibuildwheel-related issue when building Python wheels on Linux.
2 parents 8dedd74 + 03af078 commit 3a6abc4

File tree

7 files changed

+273
-98
lines changed

7 files changed

+273
-98
lines changed

.github/workflows/buildThirdPartyLibrary.yml

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ jobs:
4242
os: ubuntu-22.04-arm
4343
build_type: Release
4444
- name: 'macOS (Intel)'
45-
os: macos-14
45+
os: macos-13
4646
build_type: Release
47-
target_arch: " -DTARGET_ARCHITECTURE=Intel"
4847
- name: 'macOS (ARM)'
4948
os: macos-14
5049
build_type: Release
@@ -76,16 +75,10 @@ jobs:
7675
- name: Configure libOpenCOR (only when building LLVM+Clang)
7776
if: ${{ inputs.third_party_library_name == 'LLVMClang' }}
7877
shell: bash
79-
run: |
80-
mkdir build
81-
cd build
82-
cmake -G Ninja ${{ matrix.target_arch }} -DBUILD_TYPE=${{ matrix.build_type }} -DONLY_BUILD_THIRD_PARTY_LIBRARIES=ON -DPREBUILT_LLVMCLANG=OFF ..
78+
run: cmake -G Ninja -S . -B build -DBUILD_TYPE=${{ matrix.build_type }} -DONLY_BUILD_THIRD_PARTY_LIBRARIES=ON -DPREBUILT_LLVMCLANG=OFF
8379
- name: Configure libOpenCOR (only when NOT building LLVM+Clang)
8480
if: ${{ inputs.third_party_library_name != 'LLVMClang' }}
85-
run: |
86-
mkdir build
87-
cd build
88-
cmake -G Ninja ${{ matrix.target_arch }} -DBUILD_TYPE=${{ matrix.build_type }} -DONLY_BUILD_THIRD_PARTY_LIBRARIES=ON -DPREBUILT_${{ inputs.third_party_library_name }}=OFF ..
81+
run: cmake -G Ninja -S . -B build -DBUILD_TYPE=${{ matrix.build_type }} -DONLY_BUILD_THIRD_PARTY_LIBRARIES=ON -DPREBUILT_${{ inputs.third_party_library_name }}=OFF
8982
- name: Upload library artifact
9083
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
9184
uses: actions/upload-artifact@v4
@@ -117,14 +110,9 @@ jobs:
117110
- name: Install Emscripten
118111
run: brew install emscripten
119112
- name: Configure libOpenCOR
120-
run: |
121-
mkdir build
122-
cd build
123-
cmake -G Ninja -DBUILD_TYPE=Release -DJAVASCRIPT_BINDINGS=ON -DONLY_BUILD_THIRD_PARTY_LIBRARIES=ON -DPREBUILT_${{ inputs.third_party_library_name }}=OFF ..
113+
run: cmake -G Ninja -S . -B build -DBUILD_TYPE=Release -DJAVASCRIPT_BINDINGS=ON -DONLY_BUILD_THIRD_PARTY_LIBRARIES=ON -DPREBUILT_${{ inputs.third_party_library_name }}=OFF
124114
- name: Build WebAssembly
125-
run: |
126-
cd build
127-
ninja
115+
run: cmake --build build
128116
- name: Upload WebAssembly artifact
129117
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
130118
uses: actions/upload-artifact@v4

.github/workflows/cd.yml

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -62,25 +62,19 @@ jobs:
6262
build_type: Release
6363
shared_libs: ON
6464
- name: 'macOS static library (Intel)'
65-
os: macos-14
66-
arch: Intel # Only used for buildcache's cache key.
65+
os: macos-13
6766
build_type: Release
6867
shared_libs: OFF
69-
target_arch: " -DTARGET_ARCHITECTURE=Intel"
7068
- name: 'macOS shared library (Intel)'
71-
os: macos-14
72-
arch: Intel # Only used for buildcache's cache key.
69+
os: macos-13
7370
build_type: Release
7471
shared_libs: ON
75-
target_arch: " -DTARGET_ARCHITECTURE=Intel"
7672
- name: 'macOS static library (ARM)'
7773
os: macos-14
78-
arch: ARM # Only used for buildcache's cache key.
7974
build_type: Release
8075
shared_libs: OFF
8176
- name: 'macOS shared library (ARM)'
8277
os: macos-14
83-
arch: ARM # Only used for buildcache's cache key.
8478
build_type: Release
8579
shared_libs: ON
8680
env:
@@ -102,21 +96,16 @@ jobs:
10296
- name: Install buildcache
10397
uses: opencor/buildcache-action@v1
10498
with:
105-
cache_key: cd-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.shared_libs }}
99+
cache_key: cd-${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.shared_libs }}
106100
- name: Configure MSVC
107101
if: ${{ runner.os == 'Windows' }}
108102
uses: ilammy/msvc-dev-cmd@v1
109103
with:
110104
arch: ${{ matrix.arch }}
111105
- name: Configure libOpenCOR
112-
run: |
113-
mkdir build
114-
cd build
115-
cmake -G Ninja ${{ matrix.target_arch }} -DBUILD_TYPE=${{ matrix.build_type }} -DCODE_ANALYSIS=OFF -DCODE_COVERAGE=OFF -DDOCUMENTATION=OFF -DJAVASCRIPT_BINDINGS=OFF -DMEMORY_CHECKS=OFF -DPYTHON_BINDINGS=OFF -DPYTHON_UNIT_TESTING=OFF -DSHARED_LIBS=${{ matrix.shared_libs }} -DUNIT_TESTING=OFF ..
106+
run: cmake -G Ninja -S . -B build -DBUILD_TYPE=${{ matrix.build_type }} -DCODE_ANALYSIS=OFF -DCODE_COVERAGE=OFF -DDOCUMENTATION=OFF -DJAVASCRIPT_BINDINGS=OFF -DMEMORY_CHECKS=OFF -DPYTHON_BINDINGS=OFF -DPYTHON_UNIT_TESTING=OFF -DSHARED_LIBS=${{ matrix.shared_libs }} -DUNIT_TESTING=OFF
116107
- name: Build libOpenCOR
117-
run: |
118-
cd build
119-
ninja
108+
run: cmake --build build
120109
- name: Package libOpenCOR
121110
run: |
122111
cd build
@@ -168,16 +157,21 @@ jobs:
168157
with:
169158
arch: ${{ matrix.arch }}
170159
- name: Build Python wheels
171-
uses: pypa/cibuildwheel@9c75ea15c2f31a77e6043b80b1b7081372319d85
160+
uses: pypa/cibuildwheel@v2.23.3
172161
env:
173162
CIBW_ARCHS: auto64
163+
CIBW_BEFORE_ALL_LINUX: >
164+
export USR_LIB_PATH=/usr/lib/`uname -m`-linux-gnu &&
165+
mkdir -p $USR_LIB_PATH &&
166+
cd $USR_LIB_PATH &&
167+
ln -s /usr/lib64/libz.so
174168
CIBW_BUILD: 'cp*'
175169
CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET=13.0
176170
# Note #1: the value of CIBW_ENVIRONMENT_MACOS must be in sync with that of MACOS_DEPLOYMENT_TARGET in
177171
# CMakelists.txt.
178172
# Note #2: for some reasons, we need to specify the minor version, hence using 13.0 instead of 13.
179-
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_34
180-
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_34
173+
CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux_2_34_x86_64
174+
CIBW_MANYLINUX_AARCH64_IMAGE: quay.io/pypa/manylinux_2_34_aarch64
181175
CIBW_SKIP: 'cp36* cp37* cp38* *musllinux*'
182176
- name: Upload Python wheel artifacts
183177
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
@@ -214,14 +208,9 @@ jobs:
214208
- name: Install Emscripten
215209
run: brew install emscripten
216210
- name: Configure libOpenCOR
217-
run: |
218-
mkdir build
219-
cd build
220-
cmake -G Ninja -DBUILD_TYPE=Release -DCODE_ANALYSIS=OFF -DCODE_COVERAGE=OFF -DDOCUMENTATION=OFF -DJAVASCRIPT_BINDINGS=ON -DJAVASCRIPT_UNIT_TESTING=OFF -DMEMORY_CHECKS=OFF -DPYTHON_BINDINGS=OFF -DPYTHON_UNIT_TESTING=OFF -DSHARED_LIBS=OFF -DUNIT_TESTING=OFF ..
211+
run: cmake -G Ninja -S . -B build -DBUILD_TYPE=Release -DCODE_ANALYSIS=OFF -DCODE_COVERAGE=OFF -DDOCUMENTATION=OFF -DJAVASCRIPT_BINDINGS=ON -DJAVASCRIPT_UNIT_TESTING=OFF -DMEMORY_CHECKS=OFF -DPYTHON_BINDINGS=OFF -DPYTHON_UNIT_TESTING=OFF -DSHARED_LIBS=OFF -DUNIT_TESTING=OFF
221212
- name: Build WebAssembly
222-
run: |
223-
cd build
224-
ninja
213+
run: cmake --build build
225214
- name: Upload WebAssembly artifact
226215
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}
227216
uses: actions/upload-artifact@v4

.github/workflows/ci.yml

Lines changed: 43 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ jobs:
4141
unit_testing: ON
4242
target: unit_testing
4343
install_uninstall_and_package: ON
44+
copy_dll: ON
4445
- name: 'Windows static library (ARM)'
4546
os: windows-11-arm
4647
arch: amd64_arm64
@@ -69,6 +70,7 @@ jobs:
6970
unit_testing: ON
7071
target: unit_testing
7172
install_uninstall_and_package: ON
73+
copy_dll: ON
7274
- name: 'Linux static library (Intel)'
7375
os: ubuntu-22.04
7476
build_type: Release
@@ -82,6 +84,7 @@ jobs:
8284
unit_testing: ON
8385
target: unit_testing
8486
install_uninstall_and_package: ON
87+
use_install_prefix: ON
8588
- name: 'Linux shared library (Intel)'
8689
os: ubuntu-22.04
8790
build_type: Release
@@ -95,6 +98,7 @@ jobs:
9598
unit_testing: ON
9699
target: unit_testing
97100
install_uninstall_and_package: ON
101+
use_install_prefix: ON
98102
- name: 'Linux static library (ARM)'
99103
os: ubuntu-22.04-arm
100104
build_type: Release
@@ -108,6 +112,7 @@ jobs:
108112
unit_testing: ON
109113
target: unit_testing
110114
install_uninstall_and_package: ON
115+
use_install_prefix: ON
111116
- name: 'Linux shared library (ARM)'
112117
os: ubuntu-22.04-arm
113118
build_type: Release
@@ -121,8 +126,9 @@ jobs:
121126
unit_testing: ON
122127
target: unit_testing
123128
install_uninstall_and_package: ON
129+
use_install_prefix: ON
124130
- name: 'macOS static library (Intel)'
125-
os: macos-14
131+
os: macos-13
126132
build_type: Release
127133
code_analysis: OFF
128134
code_coverage: OFF
@@ -133,10 +139,10 @@ jobs:
133139
shared_libs: OFF
134140
unit_testing: ON
135141
target: unit_testing
136-
target_arch: " -DTARGET_ARCHITECTURE=Intel"
137142
install_uninstall_and_package: ON
143+
use_install_prefix: ON
138144
- name: 'macOS shared library (Intel)'
139-
os: macos-14
145+
os: macos-13
140146
build_type: Release
141147
code_analysis: OFF
142148
code_coverage: OFF
@@ -147,8 +153,8 @@ jobs:
147153
shared_libs: ON
148154
unit_testing: ON
149155
target: unit_testing
150-
target_arch: " -DTARGET_ARCHITECTURE=Intel"
151156
install_uninstall_and_package: ON
157+
use_install_prefix: ON
152158
- name: 'macOS static library (ARM)'
153159
os: macos-14
154160
build_type: Release
@@ -162,6 +168,7 @@ jobs:
162168
unit_testing: ON
163169
target: unit_testing
164170
install_uninstall_and_package: ON
171+
use_install_prefix: ON
165172
- name: 'macOS shared library (ARM)'
166173
os: macos-14
167174
build_type: Release
@@ -175,6 +182,7 @@ jobs:
175182
unit_testing: ON
176183
target: unit_testing
177184
install_uninstall_and_package: ON
185+
use_install_prefix: ON
178186
- name: 'JavaScript bindings'
179187
os: macos-14
180188
build_type: Release
@@ -394,86 +402,65 @@ jobs:
394402
wget https://github.com/opencor/gha/releases/download/gha/doxygen.tar.gz -O - | tar -xz
395403
sudo mv doxygen /usr/local/bin
396404
- name: Configure libOpenCOR
405+
shell: bash
397406
run: |
398-
mkdir build
399-
cd build
400-
${{ matrix.context }} cmake -G Ninja ${{ matrix.target_arch }} -DBUILD_TYPE=${{ matrix.build_type }} -DCODE_ANALYSIS=${{ matrix.code_analysis }} -DCODE_COVERAGE=${{ matrix.code_coverage }} -DDOCUMENTATION=${{ matrix.documentation }} -DINSTALL_PREFIX=${{ github.workspace }}/install -DJAVASCRIPT_BINDINGS=${{ matrix.javascript_support }} -DJAVASCRIPT_UNIT_TESTING=${{ matrix.javascript_support }} -DMEMORY_CHECKS=${{ matrix.memory_checks }} -DPYTHON_BINDINGS=${{ matrix.python_support }} -DPYTHON_UNIT_TESTING=${{ matrix.python_support }} -DSHARED_LIBS=${{ matrix.shared_libs }} -DUNIT_TESTING=${{ matrix.unit_testing }} ..
407+
if [ '${{ matrix.use_install_prefix }}' == 'ON' ]; then export D_INSTALL_PREFIX='-DINSTALL_PREFIX=${{ github.workspace }}/install'; fi
408+
${{ matrix.context }} cmake -G Ninja -S . -B build -DBUILD_TYPE=${{ matrix.build_type }} -DCODE_ANALYSIS=${{ matrix.code_analysis }} -DCODE_COVERAGE=${{ matrix.code_coverage }} -DDOCUMENTATION=${{ matrix.documentation }} $D_INSTALL_PREFIX -DJAVASCRIPT_BINDINGS=${{ matrix.javascript_support }} -DJAVASCRIPT_UNIT_TESTING=${{ matrix.javascript_support }} -DMEMORY_CHECKS=${{ matrix.memory_checks }} -DPYTHON_BINDINGS=${{ matrix.python_support }} -DPYTHON_UNIT_TESTING=${{ matrix.python_support }} -DSHARED_LIBS=${{ matrix.shared_libs }} -DUNIT_TESTING=${{ matrix.unit_testing }}
401409
- name: Build libOpenCOR
402-
if: ${{ (matrix.install_uninstall_and_package == 'ON') || (matrix.javascript_support == 'ON') || (matrix.code_analysis == 'ON') || (matrix.code_coverage == 'ON') || (matrix.memory_checks == 'ON') }}
403-
run: |
404-
cd build
405-
ninja
410+
if: ${{ (matrix.install_uninstall_and_package == 'ON') || (matrix.code_analysis == 'ON') || (matrix.code_coverage == 'ON') || (matrix.memory_checks == 'ON') }}
411+
run: cmake --build build
406412
- name: Unit testing
407413
if: ${{ ((matrix.unit_testing == 'ON') && (matrix.code_analysis == 'OFF')) || (matrix.code_coverage == 'ON') || (matrix.memory_checks == 'ON') }}
408-
run: |
409-
cd build
410-
ninja ${{ matrix.target }}
414+
run: cmake --build build --target ${{ matrix.target }}
411415
- name: JavaScript unit testing
412416
if: ${{ matrix.javascript_support == 'ON' }}
413-
run: |
414-
cd build
415-
ninja ${{ matrix.target }}
417+
run: cmake --build build --target ${{ matrix.target }}
416418
- name: Python unit testing
417419
if: ${{ matrix.python_support == 'ON' }}
418-
run: |
419-
cd build
420-
ninja ${{ matrix.target }}
420+
run: cmake --build build --target ${{ matrix.target }}
421421
- name: Python unit testing report
422422
if: ${{ matrix.python_support == 'ON' }}
423-
run: |
424-
cd build
425-
ninja ${{ matrix.target }}_report
423+
run: cmake --build build --target ${{ matrix.target }}_report
426424
- name: Code formatting
427425
if: ${{ matrix.target == 'check_code_formatting' }}
428-
run: |
429-
cd build
430-
ninja ${{ matrix.target }}
426+
run: cmake --build build --target ${{ matrix.target }}
431427
- name: JavaScript code formatting
432428
if: ${{ matrix.target == 'javascript_check_code_formatting' }}
433-
run: |
434-
cd build
435-
ninja ${{ matrix.target }}
429+
run: cmake --build build --target ${{ matrix.target }}
436430
- name: Python code formatting
437431
if: ${{ matrix.target == 'python_check_code_formatting' }}
438-
run: |
439-
cd build
440-
ninja ${{ matrix.target }}
432+
run: cmake --build build --target ${{ matrix.target }}
441433
- name: Code analysis
442434
if: ${{ matrix.name == 'Code analysis' }}
443-
run: |
444-
cd build
445-
ninja
435+
run: cmake --build build
446436
- name: Code coverage
447437
if: ${{ matrix.code_coverage == 'ON' }}
448-
run: |
449-
cd build
450-
ninja ${{ matrix.target }}
451-
if [ `ninja ${{ matrix.target }} | grep TOTAL | sed 's/ /\n/g' | grep "100.00%" | wc -l | sed 's/ //g'` -eq 4 ]; then exit 0; else exit 1; fi
438+
run: if [ `cmake --build build --target ${{ matrix.target }} | grep TOTAL | sed 's/ /\n/g' | grep "100.00%" | wc -l | sed 's/ //g'` -eq 4 ]; then exit 0; else exit 1; fi
452439
- name: Code coverage report
453440
if: ${{ matrix.code_coverage == 'ON' }}
454-
run: |
455-
cd build
456-
ninja ${{ matrix.target }}_report
441+
run: cmake --build build --target ${{ matrix.target }}_report
457442
- name: Memory checks
458443
if: ${{ matrix.memory_checks == 'ON' }}
459-
run: |
460-
cd build
461-
ninja ${{ matrix.target }}
444+
run: cmake --build build --target ${{ matrix.target }}
462445
- name: Documentation
463446
if: ${{ matrix.documentation == 'ON' }}
464-
run: |
465-
cd build
466-
ninja ${{ matrix.target }}
447+
run: cmake --build build --target ${{ matrix.target }}
467448
- name: Install libOpenCOR
468449
if: ${{ matrix.install_uninstall_and_package == 'ON' }}
450+
run: cmake --build build --target install
451+
- name: Test libOpenCOR
452+
if: ${{ matrix.install_uninstall_and_package == 'ON' }}
453+
shell: bash
469454
run: |
470-
cd build
471-
ninja install
455+
cd tests/install
456+
if [ '${{ matrix.use_install_prefix }}' == 'ON' ]; then export D_CMAKE_PREFIX_PATH='-DCMAKE_PREFIX_PATH=${{ github.workspace }}/install'; fi
457+
cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} $D_CMAKE_PREFIX_PATH
458+
cmake --build build
459+
if [ '${{ matrix.copy_dll }}' == 'ON' ]; then cp "C:/Program Files (x86)/libOpenCOR/bin/libOpenCOR.dll" build; fi
460+
build/testInstall
472461
- name: Uninstall libOpenCOR
473462
if: ${{ matrix.install_uninstall_and_package == 'ON' }}
474-
run: |
475-
cd build
476-
ninja uninstall
463+
run: cmake --build build --target uninstall
477464
- name: Package libOpenCOR
478465
if: ${{ matrix.install_uninstall_and_package == 'ON' }}
479466
run: |
@@ -486,7 +473,9 @@ jobs:
486473
pip3 install .
487474
- name: Test libOpenCOR Python
488475
if: ${{ matrix.pip_install_test_and_uninstall == 'ON' }}
489-
run: python3 -c "import libopencor as oc; print(f'This is libOpenCOR version {oc.version_string()}.')"
476+
run: |
477+
cd tests/install/bindings/python
478+
python3 test_install.py
490479
- name: pip uninstall libOpenCOR
491480
if: ${{ matrix.pip_install_test_and_uninstall == 'ON' }}
492481
run: pip3 uninstall -y libopencor

cmake/packaging/patch.cmake.in

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
file(GLOB_RECURSE CMAKE_FILE "@CMAKE_PROJECT_NAME@Targets.cmake")
22
file(READ ${CMAKE_FILE} FILE_CONTENTS)
33

4-
string(REGEX REPLACE "\n[^\n]*INTERFACE_LINK_LIBRARIES[^\n]*\n" "\n" FILE_CONTENTS "${FILE_CONTENTS}")
4+
# By default, the INTERFACE_LINK_LIBRARIES entry lists all of libOpenCOR's dependencies, but we don't need them since we
5+
# embed them in our static version of libOpenCOR. However, on Windows and macOS, the INTERFACE_LINK_LIBRARIES entry
6+
# should list some needed system libraries. So, depending on the platform, we either set the INTERFACE_LINK_LIBRARIES
7+
# entry to those needed system libraries or remove the INTERFACE_LINK_LIBRARIES entry altogether.
8+
9+
if(WIN32)
10+
string(REGEX REPLACE "INTERFACE_LINK_LIBRARIES[^\n]*\n" "INTERFACE_LINK_LIBRARIES \"$<LINK_ONLY:crypt32.lib>;$<LINK_ONLY:version.lib>;$<LINK_ONLY:wldap32.lib>;$<LINK_ONLY:ws2_32.lib>\"\n" FILE_CONTENTS "${FILE_CONTENTS}")
11+
elseif(APPLE)
12+
string(REGEX REPLACE "INTERFACE_LINK_LIBRARIES[^\n]*\n" "INTERFACE_LINK_LIBRARIES \"-framework CoreFoundation;-framework SystemConfiguration;$<LINK_ONLY:ldap>\"\n" FILE_CONTENTS "${FILE_CONTENTS}")
13+
else()
14+
string(REGEX REPLACE "\n[^\n]*INTERFACE_LINK_LIBRARIES[^\n]*\n" "\n" FILE_CONTENTS "${FILE_CONTENTS}")
15+
endif()
516

617
file(WRITE ${CMAKE_FILE} "${FILE_CONTENTS}")

tests/install/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
3+
project(testInstall)
4+
5+
set(CMAKE_CXX_STANDARD 20)
6+
7+
find_package(libOpenCOR REQUIRED)
8+
9+
add_executable(${PROJECT_NAME}
10+
src/main.cpp
11+
)
12+
13+
target_link_libraries(${PROJECT_NAME} PUBLIC libOpenCOR)

0 commit comments

Comments
 (0)