Skip to content

Commit

Permalink
Updating examples to use std::lanch syntax and fixing some build erro…
Browse files Browse the repository at this point in the history
…rs in C++17
  • Loading branch information
benny-edlund committed Apr 26, 2024
1 parent 55eb3e7 commit abfbbc8
Show file tree
Hide file tree
Showing 16 changed files with 826 additions and 1,094 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set(OPT_WARNINGS_AS_ERRORS_DEVELOPER_DEFAULT TRUE)
# Set the project name and language
project(
task_pool
VERSION 3.1.0
VERSION 4.0.0
DESCRIPTION ""
HOMEPAGE_URL "%%https://github.com/benny-edlund/task-pool%%"
LANGUAGES CXX )
Expand Down Expand Up @@ -50,8 +50,8 @@ elseif(NOT PROJECT_IS_TOP_LEVEL)
return()
endif()

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}"
)

include(InstallRequiredSystemLibraries)
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_VERSION_MAJOR "${task_pool_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${task_pool_VERSION_MINOR}")
include(CPack)
4 changes: 2 additions & 2 deletions docs/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ A standard release configuration may be produced in the following way
conan install . --output-folder=build --build=missing --settings=build_type=Release
cd build
(linux/macos)
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake
cmake .. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release
(windows)
cmake .. -G "Visual Studio 17 2022" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake"
cmake .. -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release
cmake --build .
```
 
Expand Down
110 changes: 9 additions & 101 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,116 +1,24 @@
cmake_minimum_required(VERSION 3.16...3.23)

set(CMAKE_CXX_STANDARD 14)
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 OFF)
set(WARNINGS_AS_ERRORS_DEVELOPER OFF)
set(OPT_WARNINGS_AS_ERRORS_DEVELOPER_DEFAULT TRUE)

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)
# Set the project name and language
project(
task_pool_examples
VERSION 0.0.0
DESCRIPTION ""
VERSION 0.0
DESCRIPTION " "
HOMEPAGE_URL "%%https://github.com/benny-edlund/task-pool%%"
LANGUAGES CXX C)

# This variable is set by project() in CMake 3.21+
string(
COMPARE EQUAL
"${CMAKE_SOURCE_DIR}"
"${PROJECT_SOURCE_DIR}"
PROJECT_IS_TOP_LEVEL)
if(PROJECT_IS_TOP_LEVEL)
include(CTest)
if(CMAKE_COMPILER_IS_GNUCXX)
LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake_modules")
endif()
endif()
LANGUAGES CXX )

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)

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
# 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_examples::project_options INTERFACE IMPORTED)
add_library(task_pool_examples::project_warnings INTERFACE IMPORTED)

# configure files based on CMake configuration options
add_subdirectory(image_processing)
add_subdirectory(webserver)
add_subdirectory(collage)

# 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()
add_subdirectory(image_processing)
add_subdirectory(webserver)
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The examples has some external dependencies, fmt, CLI11, boost (headers) and tur

```bash
cd examples
conan install . --output-folder=build
cmake -S . -B ./build -DCMAKE_PREFIX_PATH=/path/to/install
cmake --build ./build
```
Expand Down
5 changes: 2 additions & 3 deletions examples/collage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@ target_link_libraries(example_collage PRIVATE fmt::fmt)
target_link_libraries(example_collage PRIVATE libjpeg-turbo::turbojpeg-static)
target_link_libraries(example_collage PRIVATE nlohmann_json::nlohmann_json)
target_link_libraries(example_collage PRIVATE CLI11::CLI11 )
target_link_libraries(example_collage PRIVATE CURL::CURL)
target_link_libraries(example_collage PRIVATE ncurses::libcurses)
target_link_libraries(example_collage PRIVATE project_warnings project_options )
target_link_libraries(example_collage PRIVATE CURL::libcurl)
target_link_libraries(example_collage PRIVATE ncurses::libcurses)
Loading

0 comments on commit abfbbc8

Please sign in to comment.