diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml new file mode 100644 index 0000000..2613c2e --- /dev/null +++ b/.github/workflows/cmake-multi-platform.yml @@ -0,0 +1,121 @@ +# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform. +# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml +name: Multiplatform Build + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + runs-on: ${{ matrix.runner }} + strategy: + # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. + fail-fast: false + + # Set up a matrix to run the following 3 configurations: + # 1. + # 2. + # 3. + # + # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. + matrix: + runner: [ubuntu-26.04, windows-2025-vs2026] + build_type: [Release] + c_compiler: [gcc, clang-22, cl] + include: + - runner: windows-2025-vs2026 + os: Windows + c_compiler: cl + cpp_compiler: cl + - runner: ubuntu-26.04 + c_compiler: gcc + cpp_compiler: g++ + - runner: ubuntu-26.04 + c_compiler: clang-22 + cpp_compiler: clang++-22 + exclude: + - runner: windows-2025-vs2026 + c_compiler: gcc + - runner: windows-2025-vs2026 + c_compiler: clang-22 + - runner: ubuntu-26.04 + c_compiler: cl + + steps: + - uses: actions/checkout@v4 + + - name: Install libc++ for Clang + if: matrix.c_compiler == 'clang-22' + run: | + sudo apt-get update + sudo apt-get install -y clang-22 clang-tools-22 libc++-22-dev libc++abi-22-dev + + - name: Set reusable strings + # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. + id: strings + shell: bash + run: | + echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + + - name: Create Conan Dependencies Profile + shell: bash + run: | + cat << EOF > profile.txt + [settings] + arch=x86_64 + os=$RUNNER_OS + compiler=$(sed 's/-[0-9][0-9]*$//' <<< "${{ matrix.c_compiler }}") + compiler.version=$(${{ matrix.c_compiler }} -dumpversion | cut -d. -f1) + compiler.cppstd=23 + $([[ "${{ matrix.c_compiler }}" == "gcc" ]] && echo "compiler.libcxx=libstdc++11" || echo "compiler.libcxx=libc++") + + [buildenv] + CC=${{ matrix.c_compiler }} + CXX=${{ matrix.cpp_compiler }} + + [conf] + tools.cmake.cmaketoolchain:generator=Ninja Multi-Config + tools.cmake.cmake_layout:build_folder_vars=['settings.compiler', 'settings.arch'] + EOF + + - name: Install Conan + shell: bash + run: | + pip install conan==2.29.0 + conan profile detect + + - name: Configure Conan Dependencies + shell: bash + run: > + conan install + -of ${{ steps.strings.outputs.build-output-dir }} + -s build_type=${{ matrix.build_type }} + -b=missing + -pr:a=profile.txt + ${{ github.workspace }} + + - name: Configure CMake + # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. + # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type + shell: bash + run: > + cmake + -B ${{ steps.strings.outputs.build-output-dir }} + --preset=conan-$(sed 's/-[0-9][0-9]*$//' <<< "${{ matrix.c_compiler }}")-x86_64 + -S ${{ github.workspace }} + + - name: Build + # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). + run: > + cmake + --build ${{ steps.strings.outputs.build-output-dir }} + --config ${{ matrix.build_type }} + + - name: Test + working-directory: ${{ steps.strings.outputs.build-output-dir }} + # Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + run: ctest --preset=conan-$(sed 's/-[0-9][0-9]*$//' <<< "${{ matrix.c_compiler }}")-x86_64-release diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 0861f1b..7e256a5 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,21 +1,21 @@ -name: Docker Image CI +# name: Docker Image CI -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] +# on: +# push: +# branches: [ "main" ] +# pull_request: +# branches: [ "main" ] -jobs: - build-gnu: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v5 - - name: Build the GNU Docker image - run: docker build . --file docker/Dockerfile-gcc --tag cmake-cpp-modules-template-gcc:$(date +%s) - build-clang: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v5 - - name: Build the Clang Docker image - run: docker build . --file docker/Dockerfile-clang --tag cmake-cpp-modules-template-clang:$(date +%s) +# jobs: +# build-gnu: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v5 +# - name: Build the GNU Docker image +# run: docker build . --file docker/Dockerfile-gcc --tag cmake-cpp-modules-template-gcc:$(date +%s) +# build-clang: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v5 +# - name: Build the Clang Docker image +# run: docker build . --file docker/Dockerfile-clang --tag cmake-cpp-modules-template-clang:$(date +%s) diff --git a/CMakeLists.txt b/CMakeLists.txt index e0b2f3b..45d87e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,8 +7,10 @@ if (CMAKE_VERSION VERSION_LESS "4.0.3") set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "a9e1cf81-9932-4810-974b-6eccaf14e457") elseif (CMAKE_VERSION VERSION_LESS "4.3.0") set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "d0edc3af-4c50-42ea-a356-e2862fe7a444") -else() +elseif (CMAKE_VERSION VERSION_LESS "4.4.0") set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "451f2fe2-a8a2-47c3-bc32-94786d8fc91b") +else() + set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "f35a9ac6-8463-4d38-8eec-5d6008153e7d") endif() # Project + Language diff --git a/README.md b/README.md index 53a0d9d..ec85836 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ cmake -B build/clang --preset=conan-clang-x86_64 # build cmake --build build/clang --config Release -j8 # test -ctest -C Release --test-dir build/clang --no-compress-output --verbose +ctest -preset=${CONAN_PROFILE} --no-compress-output --verbose ``` ### GNU @@ -115,7 +115,7 @@ cmake -B build/gcc --preset=conan-gcc-x86_64 # build cmake --build build/gcc --config Release -j8 # test -ctest -C Release --test-dir build/gcc --no-compress-output --verbose +ctest -preset=${CONAN_PROFILE} --no-compress-output --verbose ``` ## Dockerfile diff --git a/targets/cpp-deps-modules/libcxx/CMakeLists.txt b/targets/cpp-deps-modules/libcxx/CMakeLists.txt index dc32150..0a10811 100644 --- a/targets/cpp-deps-modules/libcxx/CMakeLists.txt +++ b/targets/cpp-deps-modules/libcxx/CMakeLists.txt @@ -21,7 +21,6 @@ target_compile_definitions(${TARGET_NAME} PRIVATE _LIBCPP_HAS_WIDE_CHARACTERS=1) target_compile_definitions(${TARGET_NAME} PRIVATE _LIBCPP_HAS_THREADS=1) target_compile_definitions(${TARGET_NAME} PRIVATE _LIBCPP_HAS_RANDOM_DEVICE=1) -FILE(GLOB_RECURSE SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cppm) target_sources(${TARGET_NAME} PUBLIC FILE_SET CXX_MODULES BASE_DIRS