0
0
mirror of https://github.com/yse/easy_profiler.git synced 2024-12-27 00:31:02 +08:00

CMake script rework

This commit is contained in:
Rokas Kupstys 2017-06-08 17:13:32 +03:00
parent c608665e06
commit f007152d2c
7 changed files with 181 additions and 371 deletions

View File

@ -1,47 +1,32 @@
project(profiling_tool) cmake_minimum_required(VERSION 2.8.12.1)
cmake_minimum_required(VERSION 2.8) project(easy_profiler CXX)
set_property(GLOBAL PROPERTY USE_FOLDERS ON) set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set( set(EASY_PROGRAM_VERSION_MAJOR 1)
EASY_ROOT set(EASY_PROGRAM_VERSION_MINOR 3)
${CMAKE_CURRENT_LIST_DIR} set(EASY_PROGRAM_VERSION_PATCH 0)
) set(EASY_PRODUCT_VERSION_STRING "${EASY_PROGRAM_VERSION_MAJOR}.${EASY_PROGRAM_VERSION_MINOR}.${EASY_PROGRAM_VERSION_PATCH}")
set(OUTPUT_DIR set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/bin)
${EASY_ROOT}/bin set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/bin)
) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY # set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_LIST_DIR}/sdk)
${OUTPUT_DIR}
)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY macro(easy_define_target_option TARGET SOURCE_OPTION TARGET_DEFINITION)
${OUTPUT_DIR} if (${SOURCE_OPTION})
) set(_VALUE 1)
else ()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY set(_VALUE 0)
${OUTPUT_DIR} endif ()
) target_compile_options(${TARGET} PUBLIC -D${TARGET_DEFINITION}=${_VALUE})
endmacro()
include_directories(
easy_profiler_core/include
)
if(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -Wno-reorder -Wno-braced-scalar-init -pedantic -O3" )
else()
add_definitions(
-D_CRT_SECURE_NO_WARNINGS
)
endif(UNIX)
#set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_LIST_DIR}/sdk)
add_subdirectory(easy_profiler_core) add_subdirectory(easy_profiler_core)
add_subdirectory(profiler_gui) add_subdirectory(profiler_gui)
add_subdirectory(sample) if (NOT EASY_PROFILER_NO_SAMPLES)
add_subdirectory(reader) add_subdirectory(sample)
add_subdirectory(reader)
endif ()

View File

@ -1,142 +1,51 @@
cmake_minimum_required(VERSION 2.8)
project(easy_profiler CXX)
IF (NOT DEFINED LIB_NAME)
SET(LIB_NAME ${PROJECT_NAME})
ENDIF()
if(NOT DEFINED EASY_PROGRAM_VERSION_MAJOR)
file (STRINGS ${CMAKE_CURRENT_LIST_DIR}/version.info EASY_PRODUCT_VERSION_STRING)
string(REPLACE "." ";" VERSION_LIST ${EASY_PRODUCT_VERSION_STRING})
list(GET VERSION_LIST 0 EASY_PROGRAM_VERSION_MAJOR)
list(GET VERSION_LIST 1 EASY_PROGRAM_VERSION_MINOR)
list(GET VERSION_LIST 2 EASY_PROGRAM_VERSION_PATCH)
# EasyProfiler version
add_definitions(
-DEASY_PROFILER_VERSION_MAJOR=${EASY_PROGRAM_VERSION_MAJOR}
-DEASY_PROFILER_VERSION_MINOR=${EASY_PROGRAM_VERSION_MINOR}
-DEASY_PROFILER_VERSION_PATCH=${EASY_PROGRAM_VERSION_PATCH}
)
# EasyProfiler version
set(EASY_PROGRAM_VERSION_MAJOR ${EASY_PROGRAM_VERSION_MAJOR} PARENT_SCOPE)
set(EASY_PROGRAM_VERSION_MINOR ${EASY_PROGRAM_VERSION_MINOR} PARENT_SCOPE)
set(EASY_PROGRAM_VERSION_PATCH ${EASY_PROGRAM_VERSION_PATCH} PARENT_SCOPE)
endif(NOT DEFINED EASY_PROGRAM_VERSION_MAJOR)
message(STATUS "") message(STATUS "")
message(STATUS "EASY_PROFILER.Core version = ${EASY_PROGRAM_VERSION_MAJOR}.${EASY_PROGRAM_VERSION_MINOR}.${EASY_PROGRAM_VERSION_PATCH}") message(STATUS "EASY_PROFILER.Core version = ${EASY_PRODUCT_VERSION_STRING}")
message(STATUS "") message(STATUS "")
set(EASY_DEFAULT_PORT 28077 CACHE STRING "Default listening port")
set(EASY_OPTION_LISTEN OFF CACHE BOOL "Enable automatic startListen on startup")
set(EASY_OPTION_PROFILE_SELF OFF CACHE BOOL "Enable self profiling (measure time for internal storage expand)")
set(EASY_OPTION_PROFILE_SELF_BLOCKS_ON OFF CACHE BOOL "Storage expand default status (profiler::ON or profiler::OFF)")
set(EASY_OPTION_LOG OFF CACHE BOOL "Print errors to stderr")
set(EASY_OPTION_PREDEFINED_COLORS OFF CACHE BOOL "Use predefined set of colors (see profiler_colors.h). If you want to use your own colors palette you can turn this option OFF")
set(EASY_OPTION_LIB_TYPE SHARED CACHE BOOL "easy_profiler library type. SHARED or STATIC")
if (WIN32)
set(EASY_OPTION_EVENT_TRACING ON CACHE BOOL "Enable event tracing by default")
set(EASY_OPTION_LOW_PRIORITY_EVENT_TRACING ON CACHE BOOL "Set low priority for event tracing thread")
endif (WIN32)
set(BUILD_WITH_CHRONO_STEADY_CLOCK OFF CACHE BOOL "Use std::chrono::steady_clock as a timer" )
set(BUILD_WITH_CHRONO_HIGH_RESOLUTION_CLOCK OFF CACHE BOOL "Use std::chrono::high_resolution_clock as a timer")
# EasyProfiler options:---------------------------------------------- message(STATUS "-------- EASY_PROFILER OPTIONS: --------")
set(EASY_DEFAULT_PORT 28077) # Default listening port if (BUILD_WITH_CHRONO_STEADY_CLOCK)
set(EASY_OPTION_LISTEN OFF) # Enable automatic startListen on startup message(STATUS " Use std::chrono::steady_clock as a timer")
set(EASY_OPTION_PROFILE_SELF OFF) # Enable self profiling (measure time for internal storage expand) elseif (BUILD_WITH_CHRONO_HIGH_RESOLUTION_CLOCK)
set(EASY_OPTION_PROFILE_SELF_BLOCKS_ON OFF) # Storage expand default status (profiler::ON or profiler::OFF) message(STATUS " Use std::chrono::high_resolution_clock as a timer")
set(EASY_OPTION_LOG OFF) # Print errors to stderr else ()
set(EASY_OPTION_PREDEFINED_COLORS ON) # Use predefined set of colors (see profiler_colors.h) if (WIN32)
# If you want to use your own colors palette you can turn this option OFF message(STATUS " Use QueryPerformanceCounter as a timer")
else ()
message(STATUS " Use rtdsc as a timer")
endif ()
endif ()
option(BUILD_WITH_CHRONO_STEADY_CLOCK "Use std::chrono::steady_clock as a timer" OFF) message(STATUS " Default listening port = ${EASY_DEFAULT_PORT}")
option(BUILD_WITH_CHRONO_HIGH_RESOLUTION_CLOCK "Use std::chrono::high_resolution_clock as a timer" OFF) message(STATUS " Auto-start listening = ${EASY_OPTION_LISTEN}")
message(STATUS " Profile self = ${EASY_OPTION_PROFILE_SELF}")
if(BUILD_WITH_CHRONO_STEADY_CLOCK) message(STATUS " Profile self blocks initial status = ${EASY_OPTION_PROFILE_SELF_BLOCKS_ON}")
add_definitions( if (WIN32)
-DEASY_CHRONO_STEADY_CLOCK message(STATUS " Event tracing = ${EASY_OPTION_EVENT_TRACING}")
) if (EASY_OPTION_LOW_PRIORITY_EVENT_TRACING)
endif(BUILD_WITH_CHRONO_STEADY_CLOCK) message(STATUS " Event tracing has low priority = Yes")
else ()
if(BUILD_WITH_CHRONO_HIGH_RESOLUTION_CLOCK) message(STATUS " Event tracing has low priority = No")
add_definitions( endif (EASY_OPTION_LOW_PRIORITY_EVENT_TRACING)
-DEASY_CHRONO_HIGHRES_CLOCK endif (WIN32)
) message(STATUS " Log messages = ${EASY_OPTION_LOG}")
endif(BUILD_WITH_CHRONO_HIGH_RESOLUTION_CLOCK) message(STATUS " Use EasyProfiler colors palette = ${EASY_OPTION_PREDEFINED_COLORS}")
message(STATUS " Library type: ${EASY_OPTION_LIB_TYPE}")
if(WIN32) message(STATUS "------ END EASY_PROFILER OPTIONS -------")
set(EASY_OPTION_EVENT_TRACING ON) # Enable event tracing by default message(STATUS "")
set(EASY_OPTION_LOW_PRIORITY_EVENT_TRACING ON) # Set low priority for event tracing thread
endif(WIN32)
MESSAGE(STATUS "EASY_PROFILER OPTIONS:--------------")
if(BUILD_WITH_CHRONO_STEADY_CLOCK)
MESSAGE(STATUS " Use std::chrono::steady_clock as a timer")
elseif(BUILD_WITH_CHRONO_HIGH_RESOLUTION_CLOCK)
MESSAGE(STATUS " Use std::chrono::high_resolution_clock as a timer")
else()
if(WIN32)
MESSAGE(STATUS " Use QueryPerformanceCounter as a timer")
else()
MESSAGE(STATUS " Use rtdsc as a timer")
endif(WIN32)
endif(BUILD_WITH_CHRONO_STEADY_CLOCK)
MESSAGE(STATUS " Default listening port = ${EASY_DEFAULT_PORT}")
MESSAGE(STATUS " Auto-start listening = ${EASY_OPTION_LISTEN}")
MESSAGE(STATUS " Profile self = ${EASY_OPTION_PROFILE_SELF}")
MESSAGE(STATUS " Profile self blocks initial status = ${EASY_OPTION_PROFILE_SELF_BLOCKS_ON}")
if(WIN32)
MESSAGE(STATUS " Event tracing = ${EASY_OPTION_EVENT_TRACING}")
if(EASY_OPTION_LOW_PRIORITY_EVENT_TRACING)
MESSAGE(STATUS " Event tracing has low priority = Yes")
else()
MESSAGE(STATUS " Event tracing has low priority = No")
endif(EASY_OPTION_LOW_PRIORITY_EVENT_TRACING)
endif(WIN32)
MESSAGE(STATUS " Log messages = ${EASY_OPTION_LOG}")
MESSAGE(STATUS " Use EasyProfiler colors palette = ${EASY_OPTION_PREDEFINED_COLORS}")
MESSAGE(STATUS "END EASY_PROFILER OPTIONS.----------")
MESSAGE(STATUS "")
# END EasyProfiler options.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
add_definitions(-DEASY_DEFAULT_PORT=${EASY_DEFAULT_PORT})
if(EASY_OPTION_LISTEN)
add_definitions(-DEASY_OPTION_START_LISTEN_ON_STARTUP=1)
else()
add_definitions(-DEASY_OPTION_START_LISTEN_ON_STARTUP=0)
endif(EASY_OPTION_LISTEN)
if(EASY_OPTION_PROFILE_SELF)
add_definitions(-DEASY_OPTION_MEASURE_STORAGE_EXPAND=1)
if(EASY_OPTION_PROFILE_SELF_BLOCKS_ON)
add_definitions(-DEASY_OPTION_STORAGE_EXPAND_BLOCKS_ON=true)
else()
add_definitions(-DEASY_OPTION_STORAGE_EXPAND_BLOCKS_ON=false)
endif(EASY_OPTION_PROFILE_SELF_BLOCKS_ON)
else()
add_definitions(-DEASY_OPTION_MEASURE_STORAGE_EXPAND=0)
endif(EASY_OPTION_PROFILE_SELF)
if(WIN32)
if(EASY_OPTION_EVENT_TRACING)
add_definitions(-DEASY_OPTION_EVENT_TRACING_ENABLED=true)
else()
add_definitions(-DEASY_OPTION_EVENT_TRACING_ENABLED=false)
endif(EASY_OPTION_EVENT_TRACING)
if(EASY_OPTION_LOW_PRIORITY_EVENT_TRACING)
add_definitions(-DEASY_OPTION_LOW_PRIORITY_EVENT_TRACING=true)
else()
add_definitions(-DEASY_OPTION_LOW_PRIORITY_EVENT_TRACING=false)
endif(EASY_OPTION_LOW_PRIORITY_EVENT_TRACING)
endif(WIN32)
if(EASY_OPTION_LOG)
add_definitions(-DEASY_OPTION_LOG_ENABLED=1)
else()
add_definitions(-DEASY_OPTION_LOG_ENABLED=0)
endif(EASY_OPTION_LOG)
if(EASY_OPTION_PREDEFINED_COLORS)
add_definitions(-DEASY_OPTION_BUILTIN_COLORS=1)
else()
add_definitions(-DEASY_OPTION_BUILTIN_COLORS=0)
endif(EASY_OPTION_PREDEFINED_COLORS)
set(CPP_FILES set(CPP_FILES
block.cpp block.cpp
@ -147,27 +56,24 @@ set(CPP_FILES
) )
set(H_FILES set(H_FILES
profile_manager.h profile_manager.h
spin_lock.h spin_lock.h
event_trace_win.h event_trace_win.h
current_time.h current_time.h
) )
include_directories(
include
)
set(INCLUDE_FILES set(INCLUDE_FILES
include/easy/profiler.h include/easy/profiler.h
include/easy/reader.h include/easy/reader.h
include/easy/easy_net.h include/easy/easy_net.h
include/easy/easy_socket.h include/easy/easy_socket.h
include/easy/easy_compiler_support.h include/easy/easy_compiler_support.h
include/easy/profiler_aux.h include/easy/profiler_aux.h
include/easy/profiler_colors.h include/easy/profiler_colors.h
include/easy/reader.h include/easy/reader.h
include/easy/serialized_block.h include/easy/serialized_block.h
) )
source_group(include FILES ${INCLUDE_FILES}) source_group(include FILES ${INCLUDE_FILES})
set(SOURCES set(SOURCES
@ -175,44 +81,55 @@ set(SOURCES
${H_FILES} ${H_FILES}
${INCLUDE_FILES} ${INCLUDE_FILES}
) )
add_definitions(
-D_BUILD_PROFILER add_library(easy_profiler ${EASY_OPTION_LIB_TYPE} ${SOURCES} resources.rc)
-DBUILD_WITH_EASY_PROFILER target_include_directories(easy_profiler PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include> # <prefix>/include
)
target_compile_definitions(easy_profiler PRIVATE
-D_BUILD_PROFILER=1
#-DEASY_PROFILER_API_DISABLED # uncomment this to disable profiler api only (you will have to rebuild only easy_profiler) #-DEASY_PROFILER_API_DISABLED # uncomment this to disable profiler api only (you will have to rebuild only easy_profiler)
) )
target_compile_definitions(easy_profiler PUBLIC
-DEASY_PROFILER_VERSION_MAJOR=${EASY_PROGRAM_VERSION_MAJOR}
-DEASY_PROFILER_VERSION_MINOR=${EASY_PROGRAM_VERSION_MINOR}
-DEASY_PROFILER_VERSION_PATCH=${EASY_PROGRAM_VERSION_PATCH}
-DEASY_DEFAULT_PORT=${EASY_DEFAULT_PORT}
-DBUILD_WITH_EASY_PROFILER=1
)
if(WIN32) easy_define_target_option(easy_profiler BUILD_WITH_CHRONO_STEADY_CLOCK EASY_CHRONO_STEADY_CLOCK)
add_definitions( easy_define_target_option(easy_profiler BUILD_WITH_CHRONO_HIGH_RESOLUTION_CLOCK EASY_CHRONO_HIGHRES_CLOCK)
-D_WINSOCK_DEPRECATED_NO_WARNINGS easy_define_target_option(easy_profiler EASY_OPTION_LISTEN EASY_OPTION_START_LISTEN_ON_STARTUP)
-D_CRT_SECURE_NO_WARNINGS easy_define_target_option(easy_profiler EASY_OPTION_PROFILE_SELF EASY_OPTION_MEASURE_STORAGE_EXPAND)
) easy_define_target_option(easy_profiler EASY_OPTION_PROFILE_SELF_BLOCKS_ON EASY_OPTION_STORAGE_EXPAND_BLOCKS_ON)
endif(WIN32) if (WIN32)
easy_define_target_option(easy_profiler EASY_OPTION_EVENT_TRACING EASY_OPTION_EVENT_TRACING_ENABLED)
easy_define_target_option(easy_profiler EASY_OPTION_LOW_PRIORITY_EVENT_TRACING EASY_OPTION_LOW_PRIORITY_EVENT_TRACING)
endif ()
easy_define_target_option(easy_profiler EASY_OPTION_LOG EASY_OPTION_LOG_ENABLED)
easy_define_target_option(easy_profiler EASY_OPTION_PREDEFINED_COLORS EASY_OPTION_BUILTIN_COLORS)
add_library(${LIB_NAME} SHARED ${SOURCES} resources.rc) if (UNIX)
target_compile_options(easy_profiler PRIVATE -Wall -Wno-long-long -Wno-reorder -Wno-braced-scalar-init -pedantic -O3)
target_link_libraries(easy_profiler pthread)
elseif (WIN32)
target_compile_definitions(easy_profiler PRIVATE -D_WIN32_WINNT=0x0600 -D_CRT_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS)
target_link_libraries(easy_profiler ws2_32 psapi)
endif ()
if (MINGW) if (MINGW)
add_definitions( target_compile_definitions(easy_profiler PRIVATE -DSTRSAFE_NO_DEPRECATE)
-D_WIN32_WINNT=0x0600 endif ()
-DSTRSAFE_NO_DEPRECATE
) if (CMAKE_VERSION VERSION_LESS "3.1")
set (PLATFORM_LIBS ${PLATFORM_LIBS} ws2_32 psapi) if (NOT MSVC)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") target_compile_options(easy_profiler PUBLIC $<$<COMPILE_LANGUAGE:CXX>:-std=gnu++11>)
elseif (CMAKE_VERSION VERSION_LESS "3.1") endif ()
if (UNIX OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set (CMAKE_CXX_FLAGS "-std=gnu++11 ${CMAKE_CXX_FLAGS}")
endif (UNIX OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
else () else ()
set_target_properties(${LIB_NAME} PROPERTIES set_target_properties(easy_profiler PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON)
CXX_STANDARD 11 endif ()
CXX_STANDARD_REQUIRED ON
)
endif (MINGW)
if(UNIX)
set(PLATFORM_LIBS ${PLATFORM_LIBS} pthread)
endif(UNIX)
target_link_libraries(${LIB_NAME} ${PLATFORM_LIBS})
#### ####
# Installation # Installation
@ -231,10 +148,10 @@ include(InstallRequiredSystemLibraries)
write_basic_package_version_file( write_basic_package_version_file(
"${version_config}" "${version_config}"
VERSION VERSION
${EASY_PRODUCT_VERSION_STRING} ${EASY_PRODUCT_VERSION_STRING}
COMPATIBILITY COMPATIBILITY
SameMajorVersion SameMajorVersion
) )
configure_package_config_file( configure_package_config_file(
@ -266,12 +183,12 @@ install(
install( install(
TARGETS TARGETS
${LIB_NAME} easy_profiler
EXPORT EXPORT
${targets_export_name} ${targets_export_name}
DESTINATION DESTINATION
bin bin
INCLUDES DESTINATION "${include_install_dir}" INCLUDES DESTINATION "${include_install_dir}"
) )
install( install(
@ -279,4 +196,4 @@ install(
DESTINATION "${config_install_dir}" DESTINATION "${config_install_dir}"
) )
target_compile_definitions(easy_profiler PUBLIC BUILD_WITH_EASY_PROFILER) target_compile_definitions(easy_profiler PUBLIC )

View File

@ -48,18 +48,18 @@ The Apache License, Version 2.0 (the "License");
#if defined(_WIN32) && defined(_MSC_VER) && _MSC_VER <= 1800 #if defined(_WIN32) && defined(_MSC_VER) && _MSC_VER <= 1800
// std::chrono for MSVC2013 is broken - it has very low resolution of 16ms // std::chrono for MSVC2013 is broken - it has very low resolution of 16ms
// restrict usage of std::chrono // restrict usage of std::chrono
# ifdef EASY_CHRONO_HIGHRES_CLOCK # if EASY_CHRONO_HIGHRES_CLOCK
# undef EASY_CHRONO_HIGHRES_CLOCK # undef EASY_CHRONO_HIGHRES_CLOCK
# endif # endif
# ifdef EASY_CHRONO_STEADY_CLOCK # if EASY_CHRONO_STEADY_CLOCK
# undef EASY_CHRONO_STEADY_CLOCK # undef EASY_CHRONO_STEADY_CLOCK
# endif # endif
#endif #endif
#if defined(EASY_CHRONO_HIGHRES_CLOCK) #if EASY_CHRONO_HIGHRES_CLOCK
# include <chrono> # include <chrono>
# define EASY_CHRONO_CLOCK std::chrono::high_resolution_clock # define EASY_CHRONO_CLOCK std::chrono::high_resolution_clock
#elif defined(EASY_CHRONO_STEADY_CLOCK) #elif EASY_CHRONO_STEADY_CLOCK
# include <chrono> # include <chrono>
# define EASY_CHRONO_CLOCK std::chrono::steady_clock # define EASY_CHRONO_CLOCK std::chrono::steady_clock
#elif defined(_WIN32) #elif defined(_WIN32)
@ -74,7 +74,7 @@ The Apache License, Version 2.0 (the "License");
static inline profiler::timestamp_t getCurrentTime() static inline profiler::timestamp_t getCurrentTime()
{ {
#if defined(EASY_CHRONO_HIGHRES_CLOCK) || defined(EASY_CHRONO_STEADY_CLOCK) #if EASY_CHRONO_HIGHRES_CLOCK || EASY_CHRONO_STEADY_CLOCK
return (profiler::timestamp_t)EASY_CHRONO_CLOCK::now().time_since_epoch().count(); return (profiler::timestamp_t)EASY_CHRONO_CLOCK::now().time_since_epoch().count();
#elif defined(_WIN32) #elif defined(_WIN32)
//see https://msdn.microsoft.com/library/windows/desktop/dn553408(v=vs.85).aspx //see https://msdn.microsoft.com/library/windows/desktop/dn553408(v=vs.85).aspx

View File

@ -1 +0,0 @@
1.3.0

View File

@ -1,7 +1,3 @@
cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
project(profiler_gui CXX)
#set(CMAKE_PREFIX_PATH f:/qt/5.5/5.6/msvc2013_64/lib/cmake) #set(CMAKE_PREFIX_PATH f:/qt/5.5/5.6/msvc2013_64/lib/cmake)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
@ -10,78 +6,48 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(Qt5Widgets) find_package(Qt5Widgets)
if(Qt5Widgets_FOUND) if (Qt5Widgets_FOUND)
if (NOT("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") AND WIN32)
if(NOT DEFINED EASY_PROGRAM_VERSION_MAJOR) set(APPLICATION_PLATFORM WIN32)
set(EASY_PROGRAM_VERSION_MAJOR 1) endif ()
set(EASY_PROGRAM_VERSION_MINOR 0) add_executable(profiler_gui ${APPLICATION_PLATFORM}
set(EASY_PROGRAM_VERSION_PATCH 0) main.cpp
set(EASY_PRODUCT_VERSION_STRING "1.0.0") blocks_graphics_view.h
endif(NOT DEFINED EASY_PROGRAM_VERSION_MAJOR) blocks_graphics_view.cpp
blocks_tree_widget.h
add_definitions( blocks_tree_widget.cpp
-DEASY_PROFILER_VERSION_MAJOR=${EASY_PROGRAM_VERSION_MAJOR} descriptors_tree_widget.h
-DEASY_PROFILER_VERSION_MINOR=${EASY_PROGRAM_VERSION_MINOR} descriptors_tree_widget.cpp
-DEASY_PROFILER_VERSION_PATCH=${EASY_PROGRAM_VERSION_PATCH} easy_chronometer_item.h
) easy_chronometer_item.cpp
easy_frame_rate_viewer.h
add_executable(${PROJECT_NAME} easy_frame_rate_viewer.cpp
main.cpp easy_graphics_item.h
blocks_graphics_view.h easy_graphics_item.cpp
blocks_graphics_view.cpp easy_graphics_scrollbar.h
blocks_tree_widget.h easy_graphics_scrollbar.cpp
blocks_tree_widget.cpp easy_qtimer.h
descriptors_tree_widget.h easy_qtimer.cpp
descriptors_tree_widget.cpp globals.h
easy_chronometer_item.h globals.cpp
easy_chronometer_item.cpp globals_qobjects.cpp
easy_frame_rate_viewer.h main_window.h
easy_frame_rate_viewer.cpp main_window.cpp
easy_graphics_item.h tree_widget_item.h
easy_graphics_item.cpp tree_widget_item.cpp
easy_graphics_scrollbar.h tree_widget_loader.h
easy_graphics_scrollbar.cpp tree_widget_loader.cpp
easy_qtimer.h resources.qrc
easy_qtimer.cpp resources.rc
globals.h
globals.cpp
globals_qobjects.cpp
main_window.h
main_window.cpp
tree_widget_item.h
tree_widget_item.cpp
tree_widget_loader.h
tree_widget_loader.cpp
resources.qrc
resources.rc
)
if (MINGW)
add_definitions(
-D_WIN32_WINNT=0x0600
-DSTRSAFE_NO_DEPRECATE
) )
set (SPECIAL_LIB ${SPECIAL_LIB} ws2_32 psapi) target_link_libraries(profiler_gui Qt5::Widgets easy_profiler)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") if (WIN32)
elseif (CMAKE_VERSION VERSION_LESS "3.1") target_compile_definitions(profiler_gui PRIVATE -D_WIN32_WINNT=0x0600)
if (UNIX OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") endif ()
set (CMAKE_CXX_FLAGS "-std=gnu++11 ${CMAKE_CXX_FLAGS}") if (MINGW)
endif (UNIX OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") target_compile_definitions(profiler_gui PRIVATE -DSTRSAFE_NO_DEPRECATE)
endif ()
else () else ()
set_target_properties(${PROJECT_NAME} PROPERTIES message(STATUS "INFO\n\n\tQt5 not found! Generating EasyProfiler projects without GUI.\n")
CXX_STANDARD 11 endif ()
CXX_STANDARD_REQUIRED ON
)
endif (MINGW)
if(UNIX)
set(SPECIAL_LIB ${SPECIAL_LIB} pthread)
endif(UNIX)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets easy_profiler ${SPECIAL_LIB})
else()
message(STATUS "INFO\n\n\tQt5 not found! Generating EasyProfiler projects without GUI.\n")
endif(Qt5Widgets_FOUND)

View File

@ -1,21 +1,3 @@
project(profiler_reader)
set(CPP_FILES add_executable(profiler_reader main.cpp)
main.cpp target_link_libraries(profiler_reader easy_profiler)
)
set(SOURCES
${CPP_FILES}
)
add_executable(${PROJECT_NAME} ${SOURCES})
if(MINGW OR UNIX)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
endif(MINGW OR UNIX)
if(UNIX)
set(SPEC_LIB ${SPEC_LIB} pthread)
endif(UNIX)
target_link_libraries(${PROJECT_NAME} easy_profiler ${SPEC_LIB})

View File

@ -1,6 +1,3 @@
cmake_minimum_required(VERSION 2.8)
project(profiler_sample CXX)
set(CPP_FILES set(CPP_FILES
main.cpp main.cpp
) )
@ -9,47 +6,11 @@ set(SOURCES
${CPP_FILES} ${CPP_FILES}
) )
include_directories(
../easy_profiler_core/include
)
link_directories(${CMAKE_SOURCE_DIR}/../bin) link_directories(${CMAKE_SOURCE_DIR}/../bin)
add_executable(${PROJECT_NAME} ${SOURCES}) add_executable(profiler_sample ${SOURCES})
target_link_libraries(profiler_sample easy_profiler)
set(DISABLED_PROFILER_NAME add_executable(profiler_sample_disabled_profiler ${SOURCES})
"${PROJECT_NAME}_disabled_profiler" target_link_libraries(profiler_sample_disabled_profiler easy_profiler)
) target_compile_definitions(profiler_sample_disabled_profiler PRIVATE DISABLE_EASY_PROFILER)
add_executable(${DISABLED_PROFILER_NAME} ${SOURCES})
if (MINGW)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif (CMAKE_VERSION VERSION_LESS "3.1")
if (UNIX OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
endif (UNIX OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
else ()
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
)
set_target_properties(${DISABLED_PROFILER_NAME} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
)
endif (MINGW)
if(UNIX)
set(SPEC_LIB ${SPEC_LIB} pthread)
endif(UNIX)
target_link_libraries(${PROJECT_NAME} easy_profiler ${SPEC_LIB})
target_link_libraries(${DISABLED_PROFILER_NAME} easy_profiler ${SPEC_LIB})
target_compile_definitions(${PROJECT_NAME} PRIVATE BUILD_WITH_EASY_PROFILER)