From c0953fa7243535832338d094a4f4ed6616a1ab8d Mon Sep 17 00:00:00 2001 From: Tomas Jira Date: Thu, 22 Feb 2024 20:19:53 +0100 Subject: [PATCH] update CMakeLists.txt and releases --- .github/workflows/release.yml | 40 +--------------------------------- CMakeLists.txt | 41 ++++++++++++----------------------- 2 files changed, 15 insertions(+), 66 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dd638f0..e68e56f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,29 +35,6 @@ jobs: with: path: bin/primal_linux_x86-64 - build_linux_x86-64_openmp: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Install Packages - run: sudo apt install -y libboost-all-dev - - - name: Configure Primal - run: cmake -B build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DGOMP=ON - - - name: Build Primal - run: cmake --build build --parallel 2 - - - name: Rename Executable - run: mv bin/primal bin/primal_linux_x86-64_openmp - - - name: Upload Artifacts - uses: actions/upload-artifact@v3 - with: - path: bin/primal_linux_x86-64_openmp - build_windows_x86-64: runs-on: windows-latest @@ -88,7 +65,7 @@ jobs: release: runs-on: ubuntu-latest - needs: [build_linux_x86-64, build_linux_x86-64_openmp, build_windows_x86-64] + needs: [build_linux_x86-64, build_windows_x86-64] steps: - uses: actions/checkout@v3 @@ -105,14 +82,6 @@ jobs: zip -r primal_windows_x86-64.zip primal.exe LICENSE.md tar -czf primal_linux_x86-64.tar.gz primal LICENSE.md - - name: Copy x86-64_openmp Binaries to the Root Folder - run: | - cp artifact/primal_linux_x86-64_openmp primal - - - name: Create x86-64_openmp Packages - run: | - tar -czf primal_linux_x86-64_openmp.tar.gz primal LICENSE.md - - name: Release linux_x86-64 Version of Primal uses: svenstaro/upload-release-action@v2 with: @@ -126,10 +95,3 @@ jobs: repo_token: ${{secrets.GITHUB_TOKEN}} file: primal_windows_x86-64.zip tag: ${{github.ref}} - - - name: Release linux_x86-64_openmp Version of Primal - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{secrets.GITHUB_TOKEN}} - file: primal_linux_x86-64_openmp.tar.gz - tag: ${{github.ref}} diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c5aae4..7fc689b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,21 +1,20 @@ -cmake_minimum_required(VERSION 3.16) -set(CMAKE_CXX_STANDARD 20) -include(FetchContent) +# minimum cmake requirement +cmake_minimum_required(VERSION 3.18) + +# project name project(Primal) -# set output flags +# include plugins +include(FetchContent) + +# set cmake flags set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +set(CMAKE_CXX_STANDARD 20) # set compiler flags -set(CMAKE_CXX_FLAGS_DEBUG "-g -pg -O0 -fprofile-arcs -ftest-coverage -Wall -Wextra") -set(CMAKE_CXX_FLAGS_RELEASE "-s -O3") - -# disable AVX if requested -if (NOT DEFINED NOAVX OR NOT ${NOAVX}) - string(APPEND CMAKE_CXX_FLAGS_RELEASE " -mavx") -endif() -unset(NOAVX CACHE) +set(CMAKE_CXX_FLAGS_DEBUG "-g -pg -O0 -Wall -Wextra") +set(CMAKE_CXX_FLAGS_RELEASE "-mavx -s -O3") # static link on windows if (WIN32) @@ -29,30 +28,18 @@ FetchContent_Declare(argparse SYSTEM GIT_REPOSITORY https://github.com/p-ranav/a # fetch the libraries FetchContent_MakeAvailable(argparse) -# find boost +# find packages +find_package(OpenMP REQUIRED) find_package(Boost REQUIRED) -# set the variable that contains the compile flags -if(${CMAKE_BUILD_TYPE} STREQUAL Debug) - set(CXXFLAGS ${CMAKE_CXX_FLAGS_DEBUG}) -elseif(${CMAKE_BUILD_TYPE} STREQUAL Release) - set(CXXFLAGS ${CMAKE_CXX_FLAGS_RELEASE}) -endif() - # include directories include_directories(include ${argparse_SOURCE_DIR}/include/argparse) -# find OpenMP if enabled -if (${GOMP}) - find_package(OpenMP REQUIRED) -endif() -unset(GOMP CACHE) - # add fractoid executable add_executable(primal src/main.cpp src/pi.cpp src/sieve.cpp src/timer.cpp) target_link_libraries(primal Boost::boost) # link OpenMP on build type -if(OPENMP_FOUND AND ${CMAKE_BUILD_TYPE} STREQUAL Release) +if(CMAKE_BUILD_TYPE STREQUAL Release) target_link_libraries(primal OpenMP::OpenMP_CXX) endif()