Skip to content

Commit

Permalink
update CMakeLists.txt and releases
Browse files Browse the repository at this point in the history
  • Loading branch information
tjira committed Feb 22, 2024
1 parent 14260c5 commit c0953fa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 66 deletions.
40 changes: 1 addition & 39 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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}}
41 changes: 14 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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()

0 comments on commit c0953fa

Please sign in to comment.