Skip to content

Commit

Permalink
Add gcc test on macos-13
Browse files Browse the repository at this point in the history
  • Loading branch information
FeignClaims committed Apr 16, 2024
1 parent c41a9e8 commit f5e7f3a
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 10 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ jobs:
compiler: "gcc"
cmake: true
vcvarsall: true
- os: "macos-13"
compiler: "gcc"
cmake: true
vcvarsall: true
exclude:
# fails with an internal error
- os: "macos-12"
Expand Down Expand Up @@ -80,7 +84,7 @@ jobs:
cppcheck: true
clangtidy: true
task: true
doxygen: ${{ !contains(matrix.os, 'macos-11') }}
doxygen: ${{ !contains(matrix.os, 'macos-11') && !contains(matrix.os, 'macos-13') }}

- name: Test
if: ${{ !cancelled() }}
Expand Down
9 changes: 9 additions & 0 deletions src/Utilities.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ function(detect_architecture arch)
endif()
endfunction()

function(detect_macos_version version)
find_program(SW_VERS_EXECUTABLE sw_vers)
execute_process(
COMMAND "${SW_VERS_EXECUTABLE}" -productVersion
OUTPUT_VARIABLE MACOS_VERSION
)
set(${version} "${MACOS_VERSION}" PARENT_SCOPE)
endfunction()

# convert semicolons in generator expression to $<SEMICOLON>
function(convert_genex_semicolons genex output)
set(result)
Expand Down
32 changes: 26 additions & 6 deletions tests/install/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@ run_conan()

project(anotherproj VERSION 0.1.0 LANGUAGES CXX C)

option(FEATURE_TESTS "Enable the tests" OFF)
if(FEATURE_TESTS)
# Enable sanitizers and static analyzers when running the tests
check_sanitizers_support(
ENABLE_SANITIZER_ADDRESS ENABLE_SANITIZER_UNDEFINED_BEHAVIOR ENABLE_SANITIZER_LEAK
ENABLE_SANITIZER_THREAD ENABLE_SANITIZER_MEMORY
)
endif()

set(ENABLE_INTERPROCEDURAL_OPTIMIZATION "ENABLE_INTERPROCEDURAL_OPTIMIZATION")
if(APPLE)
detect_macos_version(apple_version)
if(apple_version VERSION_GREATER_EQUAL 13)
# workaround for linkage error as described in https://github.com/Homebrew/homebrew-core/issues/145991
# although fixed, this problem still exists in github actions
add_link_options(-Wl,-ld_classic)
set(ENABLE_INTERPROCEDURAL_OPTIMIZATION "")
endif()
endif()

# Initialize project_options
project_options(
ENABLE_CACHE
Expand All @@ -23,14 +43,14 @@ project_options(
DOXYGEN_THEME
"${CMAKE_CURRENT_LIST_DIR}/css/my_custom_theme.css"
"${CMAKE_CURRENT_LIST_DIR}/css/my_custom_theme_extra.css"
ENABLE_INTERPROCEDURAL_OPTIMIZATION
${ENABLE_INTERPROCEDURAL_OPTIMIZATION}
# ENABLE_BUILD_WITH_TIME_TRACE
# ENABLE_UNITY
# ENABLE_SANITIZER_ADDRESS
# ENABLE_SANITIZER_LEAK
# ENABLE_SANITIZER_UNDEFINED_BEHAVIOR
# ENABLE_SANITIZER_THREAD
# ENABLE_SANITIZER_MEMORY
${ENABLE_SANITIZER_ADDRESS}
# ${ENABLE_SANITIZER_LEAK}
${ENABLE_SANITIZER_UNDEFINED_BEHAVIOR}
# ${ENABLE_SANITIZER_THREAD}
# ${ENABLE_SANITIZER_MEMORY}
)

# add src, tests, etc here:
Expand Down
13 changes: 12 additions & 1 deletion tests/myproj/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ if(NOT MSVC)
#message(STATUS "Detect Linker: ${LINKER}")
endif()

set(ENABLE_INTERPROCEDURAL_OPTIMIZATION "ENABLE_INTERPROCEDURAL_OPTIMIZATION")
if(APPLE)
detect_macos_version(apple_version)
if(apple_version VERSION_GREATER_EQUAL 13)
# workaround for linkage error as described in https://github.com/Homebrew/homebrew-core/issues/145991
# although fixed, this problem still exists in github actions
add_link_options(-Wl,-ld_classic)
set(ENABLE_INTERPROCEDURAL_OPTIMIZATION "")
endif()
endif()

# Initialize project_options
# uncomment the options to enable them
project_options(
Expand All @@ -65,7 +76,7 @@ project_options(
# PCH_HEADERS
# ${PCH_HEADERS}
ENABLE_DOXYGEN
ENABLE_INTERPROCEDURAL_OPTIMIZATION
${ENABLE_INTERPROCEDURAL_OPTIMIZATION}
ENABLE_NATIVE_OPTIMIZATION
# ENABLE_BUILD_WITH_TIME_TRACE
# ENABLE_UNITY
Expand Down
4 changes: 2 additions & 2 deletions tests/myproj/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ tasks:
cmds:
- task: build
vars:
CMAKE_ARGS: -DENABLE_CROSS_COMPILING:BOOL=ON -DCMAKE_C_COMPILER={{.CROSS_CC | default "x86_64-w64-mingw32-gcc"}} -DCMAKE_CXX_COMPILER={{.CROSS_CXX | default "x86_64-w64-mingw32-g++"}}
CMAKE_ARGS: -DFEATURE_TESTS:BOOL=ON -DENABLE_CROSS_COMPILING:BOOL=ON -DCMAKE_C_COMPILER={{.CROSS_CC | default "x86_64-w64-mingw32-gcc"}} -DCMAKE_CXX_COMPILER={{.CROSS_CXX | default "x86_64-w64-mingw32-g++"}}

build.mingw.release:
cmds:
- task: build.release
vars:
CMAKE_ARGS: -DENABLE_CROSS_COMPILING:BOOL=ON -DCMAKE_C_COMPILER={{.CROSS_CC | default "x86_64-w64-mingw32-gcc"}} -DCMAKE_CXX_COMPILER={{.CROSS_CXX | default "x86_64-w64-mingw32-g++"}}
CMAKE_ARGS: -DFEATURE_TESTS:BOOL=ON -DENABLE_CROSS_COMPILING:BOOL=ON -DCMAKE_C_COMPILER={{.CROSS_CC | default "x86_64-w64-mingw32-gcc"}} -DCMAKE_CXX_COMPILER={{.CROSS_CXX | default "x86_64-w64-mingw32-g++"}}

lint:
- ~/vcpkg/vcpkg format-manifest ./vcpkg.json
Expand Down

0 comments on commit f5e7f3a

Please sign in to comment.