diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 5e9cbca..1d29ec9 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -9,20 +9,32 @@ on: jobs: build: runs-on: ubuntu-latest + strategy: + matrix: + config: [Release, Debug] + standalone: [OFF, ON] + toolchain: [linux-gnu, linux-clang] + isPR: + - ${{ github.event_name == 'pull_request' }} + exclude: + - isPR: true + standalone: OFF steps: - uses: actions/checkout@v4 - name: Install dependencies run: sudo apt-get install cmake ninja-build libbz2-dev - name: Build run: | - cmake -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE=Release + cmake -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DPRISM_STANDALONE=${{ matrix.standalone }} -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/${{ matrix.toolchain }}.cmake cmake --build build-cmake -j - name: Create Package + if: ${{ matrix.config == 'Release' && matrix.standalone == 'ON' && matrix.toolchain == 'linux-gnu' }} run: | mkdir prism-release cp build-cmake/prism prism-release/ cp "$(ldconfig -p | grep libbz2.so.1.0 | tr ' ' '\n' | grep /| head -n1)" prism-release/ - name: Publish packaged artifacts + if: ${{ matrix.config == 'Release' && matrix.standalone == 'ON' && matrix.toolchain == 'linux-gnu' }} uses: actions/upload-artifact@v4 with: name: prism-linux-x64 diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 613f057..4e552e7 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -9,19 +9,41 @@ on: jobs: build: runs-on: macOS-latest + strategy: + matrix: + config: [Release, Debug] + standalone: [OFF, ON] + toolchain: [macos-clang, macos-gnu] # remove temporary macos-clang-llvm + isPR: + - ${{ github.event_name == 'pull_request' }} + exclude: + - isPR: true + standalone: OFF steps: - uses: actions/checkout@v4 - name: Install dependencies run: brew install cmake ninja xcodes + - name: Download llvm + if: ${{ matrix.toolchain == 'macos-clang-llvm' }} + run: | + brew install llvm lld + echo "/opt/homebrew/opt/llvm/bin" >> $GITHUB_PATH + - name: Download gnu + if: ${{ matrix.toolchain == 'macos-gnu' }} + run: | + brew install gcc + echo "/opt/homebrew/opt/gcc/bin" >> $GITHUB_PATH - name: Build run: | - cmake -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE=Release + cmake -H. -Bbuild-cmake -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.config }} -DPRISM_STANDALONE=${{ matrix.standalone }} -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/${{ matrix.toolchain }}.cmake cmake --build build-cmake -j - name: Create Package + if: ${{ matrix.config == 'Release' && matrix.standalone == 'ON' && matrix.toolchain == 'macos-clang' }} run: | mkdir prism-release cp build-cmake/prism prism-release/ - name: Publish packaged artifacts + if: ${{ matrix.config == 'Release' && matrix.standalone == 'ON' && matrix.toolchain == 'macos-clang' }} uses: actions/upload-artifact@v4 with: name: prism-mac-bin diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index f4ec709..bae8800 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -9,21 +9,47 @@ on: jobs: build: runs-on: windows-2022 + strategy: + matrix: + config: [Release, Debug] + toolchain: [windows-msvc, windows-clang-cl] + standalone: [OFF, ON] + generate: [Visual Studio 17 2022, Ninja] + arch: [x64, Win32] + isPR: + - ${{ github.event_name == 'pull_request' }} + exclude: + - toolchain: windows-clang-cl + arch: Win32 + - isPR: true + standalone: OFF steps: - uses: actions/checkout@v4 - - name: Build + - name: Build Visual Studio + if: ${{ matrix.generate == 'Visual Studio 17 2022' }} run: | - cmake -S . -B "build/x64" -G "Visual Studio 17 2022" -T v142 -A x64 -DCMAKE_BUILD_TYPE:STRING=Release - cmake --build ./build/x64 + cmake -S . -B "build/${{ matrix.arch }}" -G "${{ matrix.generate }}" -DCMAKE_TOOLCHAIN_FILE="cmake/toolchain/${{ matrix.toolchain }}.cmake" -DCMAKE_GENERATOR_PLATFORM=${{ matrix.arch }} -DCMAKE_BUILD_TYPE:STRING=${{ matrix.config }} -DPRISM_STANDALONE=${{ matrix.standalone }} + cmake --build ./build/${{ matrix.arch }} + - name: Setup Variables + if: ${{ matrix.generate == 'Ninja' }} + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: ${{ matrix.arch }} + - name: Build Ninja + if: ${{ matrix.generate == 'Ninja' }} + run: | + cmake -S . -B "build/${{ matrix.arch }}" -G "${{ matrix.generate }}" -DCMAKE_TOOLCHAIN_FILE="cmake/toolchain/${{ matrix.toolchain }}.cmake" -DCMAKE_BUILD_TYPE:STRING=${{ matrix.config }} -DPRISM_STANDALONE=${{ matrix.standalone }} + cmake --build ./build/${{ matrix.arch }} - name: Publish packaged artifacts + if: ${{ matrix.config == 'Release' && matrix.generate == 'Visual Studio 17 2022' && matrix.standalone == 'ON' }} uses: actions/upload-artifact@v4 with: - name: prism-windows-x64 - path: build/x64/Debug/prism.exe + name: prism-windows-${{ matrix.arch }}-${{ matrix.config }} + path: build/${{ matrix.arch }}/${{ matrix.config }}/prism.exe - name: Test continue-on-error: true run: | - cd build/x64 + cd build/${{ matrix.arch }} ctest -j -C Debug - name: Echo Test Results - run: cat build-cmake/Testing/Temporary/LastTest.log \ No newline at end of file + run: cat build/${{ matrix.arch }}/Testing/Temporary/LastTest.log \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index f98c95b..9da11b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,7 +55,7 @@ if (DEBUG_PARSE) add_definitions(-DDEBUG_PARSE) endif() -if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC") +if(NOT MSVC) set(CMAKE_CXX_FLAGS_DEBUG "-g") set(CMAKE_CXX_FLAGS_RELEASE "-O3") set(CMAKE_CXX_FLAGS "-Wno-narrowing") @@ -73,7 +73,6 @@ else() /W3; /${LINK_TYPE} > - /bigobj /permissive-; /MP; ${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT}; @@ -89,11 +88,14 @@ else() /INCREMENTAL:NO; /FORCE:MULTIPLE > - /bigobj; /MANIFEST:NO; /DEBUG; /SUBSYSTEM:CONSOLE ) + if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + target_compile_options(${PROJECT_NAME} PRIVATE /bigobj) + target_link_options(${PROJECT_NAME} PRIVATE /bigobj) + endif() set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif() @@ -121,7 +123,15 @@ if(PRISM_STANDALONE) target_link_libraries(${PROJECT_NAME} PRIVATE spdlog) else() find_package(spdlog QUIET) - target_link_libraries(${PROJECT_NAME} PUBLIC spdlog::spdlog) + if (NOT spdlog_FOUND) + FetchContent_Declare( + spdlog + GIT_REPOSITORY https://github.com/gabime/spdlog.git + GIT_TAG 7e635fca68d014934b4af8a1cf874f63989352b7 + ) + FetchContent_MakeAvailable(spdlog) + endif() + target_link_libraries(${PROJECT_NAME} PUBLIC spdlog::spdlog) endif() if(NOT PRISM_STANDALONE) diff --git a/cmake/toolchain/linux-clang.cmake b/cmake/toolchain/linux-clang.cmake new file mode 100644 index 0000000..e958f30 --- /dev/null +++ b/cmake/toolchain/linux-clang.cmake @@ -0,0 +1,3 @@ +set(CMAKE_C_COMPILER /usr/bin/clang) +set(CMAKE_CXX_COMPILER /usr/bin/clang++) +set(CMAKE_LINKER /usr/bin/ld) diff --git a/cmake/toolchain/linux-gnu.cmake b/cmake/toolchain/linux-gnu.cmake new file mode 100644 index 0000000..74ca215 --- /dev/null +++ b/cmake/toolchain/linux-gnu.cmake @@ -0,0 +1,3 @@ +set(CMAKE_C_COMPILER /usr/bin/gcc) +set(CMAKE_CXX_COMPILER /usr/bin/g++) +set(CMAKE_LINKER /usr/bin/ld) \ No newline at end of file diff --git a/cmake/toolchain/macos-clang-llvm.cmake b/cmake/toolchain/macos-clang-llvm.cmake new file mode 100644 index 0000000..27cc14d --- /dev/null +++ b/cmake/toolchain/macos-clang-llvm.cmake @@ -0,0 +1,3 @@ +set(CMAKE_C_COMPILER /opt/homebrew/opt/llvm/bin/clang) +set(CMAKE_CXX_COMPILER /opt/homebrew/opt/llvm/bin/clang++) +set(CMAKE_LINKER /opt/homebrew/opt/lld/bin/lld-link) diff --git a/cmake/toolchain/macos-clang.cmake b/cmake/toolchain/macos-clang.cmake new file mode 100644 index 0000000..e69de29 diff --git a/cmake/toolchain/macos-gnu.cmake b/cmake/toolchain/macos-gnu.cmake new file mode 100644 index 0000000..5e1339f --- /dev/null +++ b/cmake/toolchain/macos-gnu.cmake @@ -0,0 +1,2 @@ +set(CMAKE_C_COMPILER /usr/bin/gcc) +set(CMAKE_CXX_COMPILER /usr/bin/g++) \ No newline at end of file diff --git a/cmake/toolchain/windows-clang-cl.cmake b/cmake/toolchain/windows-clang-cl.cmake new file mode 100644 index 0000000..770c988 --- /dev/null +++ b/cmake/toolchain/windows-clang-cl.cmake @@ -0,0 +1,7 @@ +if (CMAKE_GENERATOR MATCHES "Visual Studio") + set(CMAKE_GENERATOR_TOOLSET "clangcl") +else() + set(CMAKE_C_COMPILER clang-cl.exe) + set(CMAKE_CXX_COMPILER clang-cl.exe) + set(CMAKE_LINKER lld-link.exe) +endif() \ No newline at end of file diff --git a/cmake/toolchain/windows-msvc.cmake b/cmake/toolchain/windows-msvc.cmake new file mode 100644 index 0000000..34ad8c0 --- /dev/null +++ b/cmake/toolchain/windows-msvc.cmake @@ -0,0 +1,3 @@ +if (CMAKE_GENERATOR MATCHES "Visual Studio") + set(CMAKE_GENERATOR_TOOLSET "v143") +endif() \ No newline at end of file