diff --git a/CMakeLists.txt b/CMakeLists.txt index 9218ec3d..02a88910 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,33 @@ set( HUNTER_ENABLED OFF ) option(BUILD_TESTS "Build tests" ON) option(BUILD_WITH_FPIC "Build with -fPIC" OFF) +option( BLS_PROFILING "Build for profiling" OFF ) +if( SKALED_PROFILING OR CONSENSUS_PROFILING ) + set( BLS_PROFILING ON ) +endif() +if( BLS_PROFILING ) + set( CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -pg" ) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg" ) + set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg" ) + set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg" ) +endif() + +if( CMAKE_BUILD_TYPE STREQUAL "Release" ) + set( CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -O3" ) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3" ) +elseif( CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" ) + set( CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -O3" ) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3" ) +elseif( CMAKE_BUILD_TYPE STREQUAL "MinSizeRel" ) + set( CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -Os" ) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os" ) +elseif( CMAKE_BUILD_TYPE STREQUAL "Debug" ) + set( CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -O0" ) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0" ) +else() + message( INFO "---- CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE} is not supported explicitly" ) +endif() + if(BUILD_TESTS) enable_testing() endif() @@ -114,7 +141,10 @@ else() if (EMSCRIPTEN) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=c++17")#-Werror -Wall -Wparentheses -Wunused -Wunreachable-code -Wextra -Wno-error=int-in-bool-context else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wparentheses -Wunused -Wunreachable-code -Wextra -Wno-error=int-in-bool-context -fPIC -std=c++17") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wunreachable-code -Wextra -Wno-error=int-in-bool-context -fPIC -std=c++17") + if( CMAKE_BUILD_TYPE STREQUAL "Debug" ) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wparentheses -Wunused" ) + endif() endif() endif()