diff --git a/easy_profiler_core/CMakeLists.txt b/easy_profiler_core/CMakeLists.txt index f2458ae..4f4e4d5 100644 --- a/easy_profiler_core/CMakeLists.txt +++ b/easy_profiler_core/CMakeLists.txt @@ -8,7 +8,7 @@ set(EASY_OPTION_PROFILE_SELF OFF CACHE BOOL "Enable self profilin 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 ON 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") +set(EASY_OPTION_LIB_STATIC OFF CACHE BOOL "easy_profiler static library.") 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") @@ -43,6 +43,11 @@ if (WIN32) endif (WIN32) message(STATUS " Log messages = ${EASY_OPTION_LOG}") message(STATUS " Use EasyProfiler colors palette = ${EASY_OPTION_PREDEFINED_COLORS}") +if (EASY_OPTION_LIB_STATIC) + set(EASY_OPTION_LIB_TYPE STATIC) +else () + set(EASY_OPTION_LIB_TYPE SHARED) +endif () message(STATUS " Library type: ${EASY_OPTION_LIB_TYPE}") message(STATUS "------ END EASY_PROFILER OPTIONS -------") message(STATUS "") @@ -91,6 +96,9 @@ 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) ) +if (EASY_OPTION_LIB_STATIC) + target_compile_definitions(easy_profiler PUBLIC -DEASY_PROFILER_STATIC=1) +endif () target_compile_definitions(easy_profiler PUBLIC -DEASY_PROFILER_VERSION_MAJOR=${EASY_PROGRAM_VERSION_MAJOR} -DEASY_PROFILER_VERSION_MINOR=${EASY_PROGRAM_VERSION_MINOR} @@ -123,12 +131,16 @@ if (MINGW) target_compile_definitions(easy_profiler PRIVATE -DSTRSAFE_NO_DEPRECATE) endif () -if (CMAKE_VERSION VERSION_LESS "3.1") - if (NOT MSVC) - target_compile_options(easy_profiler PUBLIC $<$:-std=gnu++11>) - endif () +if (APPLE) + target_compile_options(easy_profiler PUBLIC -std=gnu++11) else () - set_target_properties(easy_profiler PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON) + if (CMAKE_VERSION VERSION_LESS "3.1") + if (NOT MSVC) + target_compile_options(easy_profiler PUBLIC $<$:-std=gnu++11>) + endif () + else () + set_target_properties(easy_profiler PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON) + endif () endif () #### diff --git a/easy_profiler_core/include/easy/easy_compiler_support.h b/easy_profiler_core/include/easy/easy_compiler_support.h index e45d1a8..db2ade0 100644 --- a/easy_profiler_core/include/easy/easy_compiler_support.h +++ b/easy_profiler_core/include/easy/easy_compiler_support.h @@ -55,7 +55,7 @@ //#define EASY_CODE_WRAP(Code) Code -#ifdef _WIN32 +#if defined(_WIN32) && !defined(EASY_PROFILER_STATIC) // Visual Studio and MinGW # ifdef _BUILD_PROFILER # define PROFILER_API __declspec(dllexport)