Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit a9660f0c authored by Millian Poquet's avatar Millian Poquet
Browse files

[cmake] enable_optimizations + cosmetics

parent 164ea6fa
Pipeline #16410 failed with stages
in 36 minutes and 12 seconds
# Let's use at least v3.1 for sanity's sake.
# Use at least v3.1 for sanity's sake.
cmake_minimum_required(VERSION 3.1)
project("Batsim")
# Enable C++11
# Let's check that the used compiler handles c++11 correctly
# Check that the used compiler handles c++11 correctly
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8.1")
message(FATAL_ERROR "Insufficient gcc version: 4.8.1 is needed to support C++11")
......@@ -21,11 +20,12 @@ else()
message(WARNING "Unknown compiler. Make sure it fully supports C++11.")
endif()
# Let's enable C++11
# Enable C++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Options
option(enable_compile_optimizations "Enable compile optimizations" ON)
option(enable_warnings "Enable compilation warnings" ON)
option(treat_warnings_as_errors "Treat compilation warnings as compilation errors" OFF)
option(ignore_assertions "Ignore assertions, which could make the simulation unstable, but could improve its performance" OFF)
......@@ -114,7 +114,6 @@ endif()
################
# Source files #
################
## Batsim
file(GLOB batsim_SRC
"src/*.hpp"
......@@ -153,7 +152,18 @@ target_link_libraries(batsim
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/batsim
DESTINATION bin)
# Let's enable warnings if needed
# Enable or disable optimizations depending on user's will
message("enable_compile_optimizations is ${enable_compile_optimizations}")
if (enable_compile_optimizations)
set(compile_optization_flag " -O2")
else()
set(compile_optization_flag " -Og")
endif()
set_property(TARGET batsim
APPEND_STRING PROPERTY COMPILE_FLAGS ${compile_optization_flag})
# Enable warnings if needed
message("enable_warnings is ${enable_warnings}")
if (enable_warnings)
set(warning_flags " -Wall -Wextra")
......@@ -171,7 +181,7 @@ if (enable_warnings)
endif()
endif()
# Let's ignore assertions if needed (might improve performance but can be dangerous)
# Ignore assertions if needed (might improve performance but can be dangerous)
if (ignore_assertions)
target_compile_definitions(batsim PRIVATE NDEBUG)
endif()
......@@ -179,7 +189,6 @@ endif()
###########
# Testing #
###########
# Batexpe test dependency
include("${CMAKE_SOURCE_DIR}/cmake/Modules/batexpe.cmake")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment