Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Somes cmake features and update workflows to use gcc 11 #316

Merged
merged 3 commits into from
Apr 13, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 6 additions & 0 deletions .github/workflows/analysis-sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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