Skip to content

Commit

Permalink
Somes cmake features and update workflows to use gcc 11 (#316)
Browse files Browse the repository at this point in the history
Update sonarcloud version and sonar/codeql/ubuntu build to use gcc 11
Added gcc minimum version 8 in cmakelists.txt
Reorganized find_packages
Fix possible bug in the spdlog link library
  • Loading branch information
dudantas authored Apr 13, 2022
1 parent 76fd4f6 commit 905f774
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 13 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/analysis-codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ jobs:
sudo apt-get update && sudo apt-get install ccache build-essential
libluajit-5.1-dev zip
- name: Switch to gcc-11
if: ${{ matrix.language == 'cpp' }}
run: |
sudo apt install gcc-11 g++-11
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11
sudo update-alternatives --set gcc /usr/bin/gcc-11
- name: CCache
if: ${{ matrix.language == 'cpp' }}
id: ccache
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/analysis-sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:
CMAKE_BUILD_PARALLEL_LEVEL: 2
MAKEFLAGS: '-j 2'
NUMBER_OF_PROCESSORS: 2
SONAR_SCANNER_VERSION: 4.6.1.2450
SONAR_SCANNER_VERSION: 4.7.0.2747
SONAR_SERVER_URL: "https://sonarcloud.io"
BUILD_WRAPPER_OUT_DIR: bw-output

Expand All @@ -37,6 +37,12 @@ jobs:
sudo apt-get update && sudo apt-get install ccache build-essential
libluajit-5.1-dev zip
- name: Switch to gcc-11
run: |
sudo apt install gcc-11 g++-11
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11
sudo update-alternatives --set gcc /usr/bin/gcc-11
- name: CCache
id: ccache
uses: actions/cache@v3
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/build-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ jobs:
sudo apt-get update && sudo apt-get install ccache build-essential
libluajit-5.1-dev zip
- name: Switch to gcc-11
run: |
sudo apt install gcc-11 g++-11
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11
sudo update-alternatives --set gcc /usr/bin/gcc-11
- name: CCache
id: ccache
uses: actions/cache@v3
Expand Down
33 changes: 21 additions & 12 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ project(canary)
# Cmake Features
# *****************************************************************************
set(CMAKE_CXX_STANDARD 17)
# Minimum version 8 for use c++ 17
set(GNUCXX_MINIMUM_VERSION 8)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

Expand Down Expand Up @@ -97,33 +100,37 @@ if(CMAKE_BUILD_TYPE MATCHES Debug)
log_option_disabled("DEBUG LOG")
endif(CMAKE_BUILD_TYPE MATCHES Debug)

# Set for supress deprecated declarations (for GCC/GNU)
# If not is GNUCXX_MINIMUM_VERSION, return message of error
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS GNUCXX_MINIMUM_VERSION)
message(FATAL_ERROR "GCC version must be at least ${GNUCXX_MINIMUM_VERSION}!")
endif()
endif()

# *****************************************************************************
# Packages / Libs
# *****************************************************************************
find_package(spdlog REQUIRED)
find_package(LuaJIT REQUIRED)
find_package(Threads REQUIRED)
find_package(libzippp REQUIRED)
find_package(cryptopp CONFIG REQUIRED)
if (MSVC)
find_package(Boost 1.53.0 COMPONENTS system filesystem iostreams date_time REQUIRED)
find_package(cryptopp CONFIG REQUIRED)
find_package(Boost 1.53.0 COMPONENTS system filesystem iostreams date_time REQUIRED)
set(CRYPTOPP_LIBRARIES "cryptopp-static")
find_package(CURL REQUIRED)
find_package(jsoncpp REQUIRED)
find_package(LuaJIT REQUIRED)
find_package(MySQL REQUIRED)
find_package(PugiXML REQUIRED)
find_package(spdlog CONFIG REQUIRED)
find_package(Threads REQUIRED)
find_package(libzippp CONFIG REQUIRED)
else()
find_package(Boost REQUIRED COMPONENTS system filesystem iostreams date_time)
find_package(cryptopp CONFIG REQUIRED)
find_package(Boost REQUIRED COMPONENTS system filesystem iostreams date_time)
find_package(CURL CONFIG REQUIRED)
find_package(jsoncpp CONFIG REQUIRED)
find_package(LuaJIT REQUIRED)
find_package(pugixml CONFIG REQUIRED)
find_package(spdlog CONFIG REQUIRED)
find_package(Threads REQUIRED)
find_package(unofficial-libmariadb CONFIG REQUIRED)
find_package(libzippp CONFIG REQUIRED)
endif (MSVC)

include(GNUInstallDirs)
Expand Down Expand Up @@ -283,6 +290,7 @@ target_include_directories(${PROJECT_NAME}
${PUGIXML_INCLUDE_DIR}
${CRYPTOPP_INCLUDE_DIR}
${CURL_INCLUDE_DIRS}
${SPDLOG_INCLUDE_DIR}
$<TARGET_PROPERTY:jsoncpp_lib,INTERFACE_INCLUDE_DIRECTORIES>)

target_link_libraries(${PROJECT_NAME}
Expand All @@ -295,8 +303,9 @@ target_link_libraries(${PROJECT_NAME}
${CRYPTOPP_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${CURL_LIBRARIES}
${SPDLOG_LIBRARY}
fmt::fmt
jsoncpp_lib
spdlog::spdlog
libzippp::libzippp
)

Expand Down

0 comments on commit 905f774

Please sign in to comment.