-
Notifications
You must be signed in to change notification settings - Fork 18
/
profile.cmake
33 lines (29 loc) · 986 Bytes
/
profile.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# (c) https://github.com/dev-cafe/autocmake/blob/master/AUTHORS.md
# licensed under BSD-3: https://github.com/dev-cafe/autocmake/blob/master/LICENSE
#.rst:
#
# Enable profiling by appending corresponding compiler flags.
#
# Variables modified (provided the corresponding language is enabled)::
#
# CMAKE_Fortran_FLAGS
# CMAKE_C_FLAGS
# CMAKE_CXX_FLAGS
#
# autocmake.yml configuration::
#
# docopt: "--profile Enable profiling [default: False]"
# define: "'-DENABLE_PROFILING={0}'.format(arguments['--profile'])"
option(ENABLE_PROFILING "Enable profiling" OFF)
message(STATUS "Enable profiling: ${ENABLE_PROFILING}")
if(ENABLE_PROFILING)
if(DEFINED CMAKE_Fortran_COMPILER_ID)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -pg")
endif()
if(DEFINED CMAKE_C_COMPILER_ID)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -pg")
endif()
if(DEFINED CMAKE_CXX_COMPILER_ID)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -pg")
endif()
endif()