Skip to content

Commit 1c051cf

Browse files
improved build and CI (#601)
Erich (build): - adjusted install interface paths to use CMAKE_INSTALL_INCLUDEDIR - added platform-agnostic RPATH handling via helper function setup_quest_rpath - set RPATH origin for dynamic linking - passed QuEST version info to CMake Tyson (CI): - run compiled examples to test for link-time errors - temporarily disabled LCOV reporting to PRs --------- Co-authored-by: Tyson Jones <[email protected]>
1 parent 3699f7c commit 1c051cf

File tree

3 files changed

+57
-11
lines changed

3 files changed

+57
-11
lines changed

.github/workflows/audit.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,8 @@ jobs:
188188
coverage-files: ./${{ env.tracefile }}
189189
minimum-coverage: ${{ env.min_coverage }}
190190
github-token: ${{ secrets.GITHUB_TOKEN }}
191+
192+
# temporarily DISABLING above reporting of LCOV results in
193+
# PR since they're not yet representative and will only
194+
# confuse incoming unitaryHACK contributors
195+
if: false

.github/workflows/compile.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
# compilers (like libomp, CUDA, ROCm). Compilation
88
# includes the v4 unit and integration tests, the
99
# deprecated v3 tests (when possible), and all the
10-
# example programs. No compiled execs are run however.
10+
# example programs. One example executable is then
11+
# run (both C and C++ versions) to ensure the build
12+
# was successful and does not cause link-time errors.
1113
# Note that ARM compilation is not yet tested here,
1214
# but in fact Linux ARM is used by a paid test runner.
1315
#
@@ -144,6 +146,8 @@ jobs:
144146
cuda_arch: 70
145147
hip_arch: gfx801
146148
rocm_path: /opt/rocm/bin
149+
example_dir: build/examples/isolated
150+
example_fn_pref: reporting_quregs
147151

148152
# perform the job
149153
steps:
@@ -232,3 +236,16 @@ jobs:
232236
# force 'Release' build (needed by MSVC to enable optimisations)
233237
- name: Compile
234238
run: cmake --build ${{ env.build_dir }} --config Release --parallel
239+
240+
# attempt to run the compiled executable, testing for link-time errors,
241+
# logging stdout and stderr to file (to verify the executable actually ran)
242+
- name: Run (Windows)
243+
if: ${{ matrix.os == 'windows-latest' }}
244+
run: |
245+
./${{ env.example_dir }}/Release/${{ env.example_fn_pref }}_c.exe
246+
./${{ env.example_dir }}/Release/${{ env.example_fn_pref }}_cpp.exe
247+
- name: Run (non-Windows)
248+
if: ${{ matrix.os != 'windows-latest' }}
249+
run: |
250+
./${{ env.example_dir }}/${{ env.example_fn_pref }}_c
251+
./${{ env.example_dir }}/${{ env.example_fn_pref }}_cpp

CMakeLists.txt

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,15 @@ add_library(QuEST::QuEST ALIAS QuEST)
250250

251251
# Set include directories
252252
target_include_directories(QuEST
253-
PUBLIC
254-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/quest/include>
255-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
256-
$<INSTALL_INTERFACE:../quest/include>
257-
$<INSTALL_INTERFACE:..>
253+
PUBLIC
254+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/quest/include>
255+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
256+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
257+
$<INSTALL_INTERFACE:${ORG_INSTALL_PATH}>
258+
)
259+
set_target_properties(QuEST PROPERTIES
260+
VERSION ${PROJECT_VERSION}
261+
SOVERSION ${PROJECT_VERSION_MAJOR}
258262
)
259263

260264
# Add required C and C++ standards
@@ -436,15 +440,34 @@ install(TARGETS min_example
436440
RUNTIME
437441
DESTINATION ${CMAKE_INSTALL_BINDIR}
438442
)
439-
set_target_properties(min_example
440-
PROPERTIES
441-
INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}"
442-
)
443443

444444
if (BUILD_EXAMPLES)
445445
add_subdirectory(examples)
446446
endif()
447447

448+
## RATH
449+
set(BUILD_RPATH_USE_ORIGIN ON)
450+
if(APPLE)
451+
set(_RPATH_ORIGIN "@loader_path")
452+
else()
453+
set(_RPATH_ORIGIN "$ORIGIN")
454+
endif()
455+
456+
set(_INSTALL_RPATH "${_RPATH_ORIGIN}/../${CMAKE_INSTALL_LIBDIR}")
457+
set(_BUILD_RPATH "${_RPATH_ORIGIN};$<TARGET_FILE_DIR:QuEST>")
458+
459+
# A tiny helper function so you can call it for every target
460+
function(setup_quest_rpath tgt)
461+
set_target_properties(${tgt} PROPERTIES
462+
BUILD_RPATH "${_BUILD_RPATH}"
463+
INSTALL_RPATH "${_INSTALL_RPATH}"
464+
# keeps RPATH from being stripped when installing
465+
INSTALL_RPATH_USE_LINK_PATH TRUE
466+
)
467+
endfunction()
468+
469+
setup_quest_rpath(QuEST)
470+
setup_quest_rpath(min_example)
448471
## User Source
449472

450473
if (USER_SOURCE AND NOT OUTPUT_EXE)
@@ -459,9 +482,10 @@ if (USER_SOURCE AND OUTPUT_EXE)
459482
add_executable(${OUTPUT_EXE} ${USER_SOURCE})
460483
target_link_libraries(${OUTPUT_EXE} PUBLIC QuEST)
461484
install(TARGETS ${OUTPUT_EXE} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
462-
set_target_properties(${OUTPUT_EXE} PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
485+
setup_quest_rpath(${OUTPUT_EXE})
463486
endif()
464487

488+
465489
## Tests
466490

467491
if (ENABLE_TESTING)

0 commit comments

Comments
 (0)