From 010386c27442280c90524085138243f8d2dd36b7 Mon Sep 17 00:00:00 2001 From: Christian Muck Date: Sat, 3 Sep 2011 16:20:45 +0200 Subject: Optional adding of gprof compile flags. --- CMakeLists.txt | 23 ++++++++++++++++++----- src/adaptor/CMakeLists.txt | 6 ++++++ src/console/CMakeLists.txt | 6 ++++++ src/daemon/CMakeLists.txt | 3 +++ src/examples/CMakeLists.txt | 6 ++++++ src/lib/CMakeLists.txt | 4 ++++ src/tests/CMakeLists.txt | 12 ++++++++++++ 7 files changed, 55 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 76739be..ae1b99b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,7 @@ SET( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE ) PROJECT( automotive-dlt ) -# set version parameters +# Set version parameters SET( ${PROJECT_NAME}_MAJOR_VERSION 2 ) SET( ${PROJECT_NAME}_MINOR_VERSION 2 ) SET( ${PROJECT_NAME}_PATCH_LEVEL 0 ) @@ -65,16 +65,29 @@ MESSAGE("REVISION ${PRINT_VERSION_REVISION}") ##################### RPM CONFIG ######################## -set( GENIVI_RPM_RELEASE "1${SVN_REVISION}") +SET( GENIVI_RPM_RELEASE "1${SVN_REVISION}") SET( LICENSE "LGPL v2.1 with special exception" ) -set(SPEC_DIR "package") +SET( SPEC_DIR "package") ######################################################### -set(GENIVI_BUILDSYSTEM_AVAILABLE $ENV{GENIVI_BUILDSYSTEM}) +SET(GENIVI_BUILDSYSTEM_AVAILABLE $ENV{GENIVI_BUILDSYSTEM}) IF(GENIVI_BUILDSYSTEM_AVAILABLE) -include($ENV{GENIVI_BUILDSYSTEM}/cmake_extensions/GeniviCMakeExtensions.cmake) +INCLUDE($ENV{GENIVI_BUILDSYSTEM}/cmake_extensions/GeniviCMakeExtensions.cmake) ENDIF(GENIVI_BUILDSYSTEM_AVAILABLE) + +###################### GPROF Settings ################### +# Adds compile flag for gprof to target +# Run the binary +# Output: gmon.out in build directory +# Run: gprof > profile.output +SET( GPROF_DLT_DAEMON OFF ) +SET( GPROF_DLT_LIB OFF ) +SET( GPROF_DLT_EXAMPLES OFF) +SET( GPROF_DLT_TESTS OFF) +SET( GPROF_DLT_CONSOLE OFF) +SET( GPROF_DLT_ADAPTOR OFF) + SET( prefix ${CMAKE_INSTALL_PREFIX}) SET( libdir "\${exec_prefix}/lib" ) SET( includedir "\${exec_prefix}/include" ) diff --git a/src/adaptor/CMakeLists.txt b/src/adaptor/CMakeLists.txt index 8a04377..a07bcbb 100755 --- a/src/adaptor/CMakeLists.txt +++ b/src/adaptor/CMakeLists.txt @@ -37,11 +37,17 @@ set(dlt_adaptor_stdin_SRCS dlt-adaptor-stdin) add_executable(dlt-adaptor-stdin ${dlt_adaptor_stdin_SRCS}) +IF(GPROF_DLT_ADAPTOR) + SET(CMAKE_C_FLAGS "-pg") +ENDIF(GPROF_DLT_ADAPTOR) target_link_libraries(dlt-adaptor-stdin dlt) set_target_properties(dlt-adaptor-stdin PROPERTIES LINKER_LANGUAGE C) set(dlt_adaptor_udp_SRCS dlt-adaptor-udp) add_executable(dlt-adaptor-udp ${dlt_adaptor_udp_SRCS}) +IF(GPROF_DLT_ADAPTOR) + SET(CMAKE_C_FLAGS "-pg") +ENDIF(GPROF_DLT_ADAPTOR) target_link_libraries(dlt-adaptor-udp dlt) set_target_properties(dlt-adaptor-udp PROPERTIES LINKER_LANGUAGE C) diff --git a/src/console/CMakeLists.txt b/src/console/CMakeLists.txt index 6cc03ac..6de6723 100755 --- a/src/console/CMakeLists.txt +++ b/src/console/CMakeLists.txt @@ -37,11 +37,17 @@ set(dlt_convert_SRCS dlt-convert) add_executable(dlt-convert ${dlt_convert_SRCS} ${dlt_most_SRCS}) +IF(GPROF_DLT_CONSOLE) + SET(CMAKE_C_FLAGS "-pg") +ENDIF(GPROF_DLT_CONSOLE) target_link_libraries(dlt-convert dlt ${EXPAT_LIBRARIES}) set_target_properties(dlt-convert PROPERTIES LINKER_LANGUAGE C) set(dlt_receive_SRCS dlt-receive) add_executable(dlt-receive ${dlt_receive_SRCS} ${dlt_most_SRCS}) +IF(GPROF_DLT_CONSOLE) + SET(CMAKE_C_FLAGS "-pg") +ENDIF(GPROF_DLT_CONSOLE) target_link_libraries(dlt-receive dlt ${EXPAT_LIBRARIES}) set_target_properties(dlt-receive PROPERTIES LINKER_LANGUAGE C) diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt index 863036b..c9f0162 100755 --- a/src/daemon/CMakeLists.txt +++ b/src/daemon/CMakeLists.txt @@ -37,6 +37,9 @@ set(dlt_daemon_SRCS dlt-daemon dlt_daemon_common ${CMAKE_SOURCE_DIR}/src/shared/dlt_user_shared.c ${CMAKE_SOURCE_DIR}/src/shared/dlt_common.c) add_executable(dlt-daemon ${dlt_daemon_SRCS}) +IF(GPROF_DLT_DAEMON) + SET(CMAKE_C_FLAGS "-pg") +ENDIF(GPROF_DLT_DAEMON) target_link_libraries(dlt-daemon rt ${CMAKE_THREAD_LIBS_INIT}) install(TARGETS dlt-daemon diff --git a/src/examples/CMakeLists.txt b/src/examples/CMakeLists.txt index cb6fbb2..6ea331d 100755 --- a/src/examples/CMakeLists.txt +++ b/src/examples/CMakeLists.txt @@ -37,11 +37,17 @@ set(dlt_example_user_SRCS dlt-example-user) add_executable(dlt-example-user ${dlt_example_user_SRCS}) +IF(GPROF_DLT_EXAMPLES) + SET(CMAKE_C_FLAGS "-pg") +ENDIF(GPROF_DLT_EXAMPLES) target_link_libraries(dlt-example-user dlt) set_target_properties(dlt-example-user PROPERTIES LINKER_LANGUAGE C) set(dlt_example_user_func_SRCS dlt-example-user-func) add_executable(dlt-example-user-func ${dlt_example_user_func_SRCS}) +IF(GPROF_DLT_EXAMPLES) + SET(CMAKE_C_FLAGS "-pg") +ENDIF(GPROF_DLT_EXAMPLES) target_link_libraries(dlt-example-user-func dlt) set_target_properties(dlt-example-user-func PROPERTIES LINKER_LANGUAGE C) diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 2ad8ce5..4b0f4f0 100755 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -39,6 +39,10 @@ set(dlt_LIB_SRCS dlt_user dlt_client ${CMAKE_SOURCE_DIR}/src/shared/dlt_common.c add_library(dlt ${dlt_LIB_SRCS}) +IF(GPROF_DLT_LIB) + SET(CMAKE_C_FLAGS "-pg") +ENDIF(GPROF_DLT_LIB) + target_link_libraries(dlt rt ${CMAKE_THREAD_LIBS_INIT}) set_target_properties(dlt PROPERTIES VERSION 2.2.0 SOVERSION 2) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 6eb708d..691f1f0 100755 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -37,21 +37,33 @@ set(dlt_test_user_SRCS dlt-test-user) add_executable(dlt-test-user ${dlt_test_user_SRCS}) +IF(GPROF_DLT_TESTS) + SET(CMAKE_C_FLAGS "-pg") +ENDIF(GPROF_DLT_TESTS) target_link_libraries(dlt-test-user dlt) set_target_properties(dlt-test-user PROPERTIES LINKER_LANGUAGE C) set(dlt_test_client_SRCS dlt-test-client) add_executable(dlt-test-client ${dlt_test_client_SRCS}) +IF(GPROF_DLT_TESTS) + SET(CMAKE_C_FLAGS "-pg") +ENDIF(GPROF_DLT_TESTS) target_link_libraries(dlt-test-client dlt) set_target_properties(dlt-test-client PROPERTIES LINKER_LANGUAGE C) set(dlt_test_stress_SRCS dlt-test-stress) add_executable(dlt-test-stress ${dlt_test_stress_SRCS}) +IF(GPROF_DLT_TESTS) + SET(CMAKE_C_FLAGS "-pg") +ENDIF(GPROF_DLT_TESTS) target_link_libraries(dlt-test-stress dlt) set_target_properties(dlt-test-stress PROPERTIES LINKER_LANGUAGE C) set(dlt_test_internal_SRCS dlt-test-internal) add_executable(dlt-test-internal ${dlt_test_internal_SRCS}) +IF(GPROF_DLT_TESTS) + SET(CMAKE_C_FLAGS "-pg") +ENDIF(GPROF_DLT_TESTS) target_link_libraries(dlt-test-internal dlt) set_target_properties(dlt-test-internal PROPERTIES LINKER_LANGUAGE C) -- cgit v1.2.1