# HG changeset patch # User Sebastien Jodogne # Date 1479988723 -3600 # Node ID bed8e7ad8babf3e1dd1b4925ca767cd611604550 # Parent 8453d3a26421d4a8765e4fb339254b8eb276e3a6 ENABLE_PROFILING cmake option diff -r 8453d3a26421 -r bed8e7ad8bab CMakeLists.txt --- a/CMakeLists.txt Wed Nov 23 16:12:04 2016 +0100 +++ b/CMakeLists.txt Thu Nov 24 12:58:43 2016 +0100 @@ -33,6 +33,7 @@ SET(BUILD_MODALITY_WORKLISTS ON CACHE BOOL "Whether to build the sample plugin to serve modality worklists") SET(BUILD_RECOVER_COMPRESSED_FILE ON CACHE BOOL "Whether to build the companion tool to recover files compressed using Orthanc") SET(ENABLE_PKCS11 OFF CACHE BOOL "Enable PKCS#11 for HTTPS client authentication using hardware security modules and smart cards") +SET(ENABLE_PROFILING OFF CACHE BOOL "Whether to enable the generation of profiling information with gprof") # Advanced parameters to fine-tune linking against system libraries SET(USE_SYSTEM_JSONCPP ON CACHE BOOL "Use the system version of JsonCpp") diff -r 8453d3a26421 -r bed8e7ad8bab Resources/CMake/Compiler.cmake --- a/Resources/CMake/Compiler.cmake Wed Nov 23 16:12:04 2016 +0100 +++ b/Resources/CMake/Compiler.cmake Thu Nov 24 12:58:43 2016 +0100 @@ -164,6 +164,23 @@ endif() +if (DEFINED ENABLE_PROFILING AND ENABLE_PROFILING) + if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + message(WARNING "Enabling profiling on a non-debug build will not produce full information") + endif() + + if (CMAKE_COMPILER_IS_GNUCXX) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -pg") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg") + else() + message(FATAL_ERROR "Don't know how to enable profiling on your configuration") + endif() +endif() + + if (STATIC_BUILD) add_definitions(-DORTHANC_STATIC=1) else()