Skip to content

Commit

Permalink
Build update (#24)
Browse files Browse the repository at this point in the history
* Remove surplus files

* Simplified build system

* Adjusting CI

* conan CI issues

* Ci syntax issues

* setting conan version

* Adjusting dependency install

* ci

* ci

* avoiding tsan build on llvm and windows

* ci

* adding thread sanitizer to link stage as well

* Cant get thread sanitizer to link on macos

* tweaking some unit tests be less dependent on system resources

* 🎨 Committing clang-format changes

* Updates for MSVC

* 🎨 Committing clang-format changes

* ci updates for windows build

---------

Co-authored-by: Clang Robot <robot@example.com>
Co-authored-by: Benny Edlund <benny.edlund@unity3d.com>
  • Loading branch information
3 people committed Sep 17, 2023
1 parent 06dc1c2 commit e4f879c
Show file tree
Hide file tree
Showing 16 changed files with 94 additions and 1,361 deletions.
25 changes: 11 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
tags:
branches:
- main
- develop

env:
# Conan cache environment variables
Expand Down Expand Up @@ -107,23 +106,21 @@ jobs:

cmake: true
ninja: true
conan: true
vcpkg: false
ccache: true
conan: 2.0.10
ccache: false
clangtidy: ${{ env.CLANG_TIDY_VERSION }}
cppcheck: true
cppcheck: false
gcovr: true
opencppcoverage: false

- name: Cleanup Conan system packages (they are not properly cached)
run:
conan remove -f '*/system'
- name: Install dependencies
run:
conan profile detect;
conan install . --output-folder=build --build=missing --settings=build_type=${{matrix.build_type}};

# make sure coverage is only enabled for Debug builds, since it sets -O0 to make sure coverage
# has meaningful results
- name: Configure CMake
run:
cmake -S . -B ./build -G "${{matrix.generator}}" -DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}} -DENABLE_DEVELOPER_MODE:BOOL=${{matrix.developer_mode}} -DENABLE_COVERAGE:BOOL=${{ matrix.build_type == 'Debug' && matrix.developer_mode == 'OFF' }} -DGIT_SHA:STRING=${{ github.sha }}
- name: Configure
run:
cd build; cmake .. -G "${{matrix.generator}}" -DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake" -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DENABLE_DEVELOPER_MODE=${{matrix.developer_mode}} -DENABLE_COVERAGE=${{ matrix.build_type == 'Debug' && matrix.developer_mode == 'OFF' }} -DGIT_SHA:STRING=${{ github.sha }};

- name: Build
# Remove llvm from env to avoid issues with gcc
Expand All @@ -143,7 +140,7 @@ jobs:
- name: CTest
working-directory: ./build
run: |
ctest -C ${{matrix.build_type}}
ctest -C ${{matrix.build_type}} --output-on-failure
- name: CPack
if: matrix.package_generator != ''
Expand Down
49 changes: 0 additions & 49 deletions .gitlab-ci.yml

This file was deleted.

24 changes: 0 additions & 24 deletions .lgtm.yml

This file was deleted.

115 changes: 3 additions & 112 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,39 +1,22 @@
cmake_minimum_required(VERSION 3.16...3.23)

# Not ideal to use this global variable, but necessary to make sure
# that tooling and projects use the same version
set(CMAKE_CXX_STANDARD 14)

# strongly encouraged to enable this globally to avoid conflicts between
# -Wpedantic being enabled and -std=c++20 and -std=gnu++20 for example
# when compiling with PCH enabled
set(CMAKE_CXX_EXTENSIONS ON)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(ENABLE_DEVELOPER_MODE ON CACHE BOOL "Enable 'developer mode'")
set(ENABLE_DEVELOPER_MODE OFF CACHE BOOL "Enable 'developer mode'")
set(ENABLE_COVERAGE OFF CACHE BOOL "Enable 'coverage mode'")
set(OPT_WARNINGS_AS_ERRORS_DEVELOPER_DEFAULT TRUE)

# Add project_options v0.20.0
# https://github.com/cpp-best-practices/project_options
include(FetchContent)
FetchContent_Declare(_project_options URL https://github.com/aminya/project_options/archive/refs/tags/v0.20.0.zip)
FetchContent_MakeAvailable(_project_options)
include(${_project_options_SOURCE_DIR}/Index.cmake)

# uncomment to enable vcpkg:
# # Setup vcpkg - should be called before defining project()
# run_vcpkg()

# Set the project name and language
project(
task_pool
VERSION 3.1.0
DESCRIPTION ""
HOMEPAGE_URL "%%https://github.com/benny-edlund/task-pool%%"
LANGUAGES CXX C)
LANGUAGES CXX )

# This variable is set by project() in CMake 3.21+
# # This variable is set by project() in CMake 3.21+
string(
COMPARE EQUAL
"${CMAKE_SOURCE_DIR}"
Expand All @@ -49,82 +32,6 @@ endif()
set(GIT_SHA "Unknown" CACHE STRING "SHA this build was generated from")
string( SUBSTRING "${GIT_SHA}" 0 8 GIT_SHORT_SHA)

get_property(BUILDING_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(BUILDING_MULTI_CONFIG)
if(NOT CMAKE_BUILD_TYPE)
# Make sure that all supported configuration types have their
# associated conan packages available. You can reduce this
# list to only the configuration types you use, but only if one
# is not forced-set on the command line for VS
message(TRACE "Setting up multi-config build types")
set(CMAKE_CONFIGURATION_TYPES
Debug
Release
RelWithDebInfo
MinSizeRel
CACHE STRING "Enabled build types" FORCE)
else()
message(TRACE "User chose a specific build type, so we are using that")
set(CMAKE_CONFIGURATION_TYPES
${CMAKE_BUILD_TYPE}
CACHE STRING "Enabled build types" FORCE)
endif()
endif()

include(${_project_options_SOURCE_DIR}/src/DynamicProjectOptions.cmake)

# defaulted_project_options sets recommended defaults and provides user and developer
# modes and full GUI support for choosing options at configure time

# for more flexibility, look into project_options() macro

# Any default can be overridden
# set(<feature_name>_DEFAULT <value>) - set default for both user and developer modes
# set(<feature_name>_DEVELOPER_DEFAULT <value>) - set default for developer mode
# set(<feature_name>_USER_DEFAULT <value>) - set default for user mode

# Initialize project_options variable related to this project
# This overwrites `project_options` and sets `project_warnings`
# uncomment the options to enable them:
dynamic_project_options(
# Note: PCH is disabled by default in developer mode because these headers become
# globally included and they can mask other errors
PCH_HEADERS
<vector>
<string>
<memory>
<utility>
ENABLE_CONAN
# CONAN_OPTIONS # Extra options to pass to conan
# MSVC_WARNINGS # Override the defaults for the MSVC warnings
CLANG_WARNINGS # Override the defaults for the CLANG warnings
-Wno-unused-local-typedefs
# GCC_WARNINGS # Override the defaults for the GCC warnings
CPPCHECK_OPTIONS
--enable=style,performance,warning,portability
--inline-suppr
# We cannot act on a bug/missing feature of cppcheck
--suppress=cppcheckError
--suppress=internalAstError
# if a file does not have an internalAstError, we get an unmatchedSuppression error
--suppress=unmatchedSuppression
--suppress=passedByValue
--suppress=syntaxError
--suppress=constParameter # buggy
--suppress=nullPointer # buggy
--suppress=functionStatic # buggy
--suppress=constStatement # doesnt like pipes
--suppress=throwInNoexceptFunction # does not know about new(std::nothrow)
--inconclusive
)

target_compile_features(project_options INTERFACE cxx_std_${CMAKE_CXX_STANDARD})
# TODO: The INTERFACE library NAMESPACE ALIAS are missing! CK
add_library(task-pool::project_options INTERFACE IMPORTED)
add_library(task-pool::project_warnings INTERFACE IMPORTED)

# configure files based on CMake configuration options
add_subdirectory(configured_files)
add_subdirectory(lib)

# Adding the tests:
Expand All @@ -134,31 +41,15 @@ if(ENABLE_TESTING)
add_subdirectory(test)
endif()

option(ENABLE_FUZZING "Enable the fuzz tests" OFF)
if(ENABLE_FUZZING)
add_subdirectory(fuzz_test)
endif()

# If MSVC is being used, and ASAN is enabled, we need to set the debugger environment
# so that it behaves well with MSVC's debugger, and we can run the target from visual studio
if(MSVC)
get_all_installable_targets(all_targets)
message("all_targets=${all_targets}")
set_target_properties(${all_targets} PROPERTIES VS_DEBUGGER_ENVIRONMENT "PATH=$(VC_ExecutablePath_x64);%PATH%")
endif()


if(CMAKE_SKIP_INSTALL_RULES)
return()
elseif(NOT PROJECT_IS_TOP_LEVEL)
return()
endif()

package_project(TARGETS task_pool project_options project_warnings
# FIXME: this does not work! CK
# PRIVATE_DEPENDENCIES_CONFIGURED project_options project_warnings
)

set(CPACK_PACKAGE_FILE_NAME
"${CMAKE_PROJECT_NAME}-${CMAKE_PROJECT_VERSION}-${GIT_SHORT_SHA}-${CMAKE_SYSTEM_NAME}-${CMAKE_BUILD_TYPE}-${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}"
)
Expand Down

0 comments on commit e4f879c

Please sign in to comment.