diff --git a/CMakeHelpers/addBoost.cmake b/CMakeHelpers/addBoost.cmake new file mode 100644 index 0000000..616da4a --- /dev/null +++ b/CMakeHelpers/addBoost.cmake @@ -0,0 +1,34 @@ +cmake_minimum_required(VERSION 2.8) + +if(Y_BOOST_LIB_INCLUDE) + set(Boost_LIBRARIES ${Y_BOOST_LIB_PATH}) + set(Boost_INCLUDE_DIRS ${Y_BOOST_LIB_INCLUDE}) + set(SX_BOOST_LIB_PATH ${Y_BOOST_LIB_PATH}) + set(SX_BOOST_LIB_INCLUDE ${Y_BOOST_LIB_INCLUDE}) + + include_directories(${Boost_INCLUDE_DIRS}) + message("Y_BOOST_LIB_INCLUDE is set by user.") + message("Path to libraries: ${Boost_LIBRARIES}") + message("Path to includes: ${Boost_INCLUDE_DIRS}") +elseif(SX_BOOST_LIB_INCLUDE) + set(Boost_LIBRARIES ${SX_BOOST_LIB_PATH}) + set(Boost_INCLUDE_DIRS ${SX_BOOST_LIB_INCLUDE}) + + include_directories(${Boost_INCLUDE_DIRS}) + message("SX_BOOST_LIB_INCLUDE is set by user.") + message("Path to libraries: ${Boost_LIBRARIES}") + message("Path to includes: ${Boost_INCLUDE_DIRS}") + +else() + message("SX_BOOST_LIB_INCLUDE is not set by user. Searching for boost libraries.") + set(Boost_USE_MULTITHREADED ON) + find_package(Boost COMPONENTS date_time filesystem system program_options chrono thread random) + if(Boost_FOUND) + include_directories(${Boost_INCLUDE_DIRS}) + message("Boost found.") + message("Path to libraries: ${Boost_LIBRARIES}") + message("Path to includes: ${Boost_INCLUDE_DIRS}") + else() + message(STATUS "Boost libraries not found!") + endif() +endif() diff --git a/CMakeHelpers/addSpecificFlags.cmake b/CMakeHelpers/addSpecificFlags.cmake new file mode 100644 index 0000000..f4df55b --- /dev/null +++ b/CMakeHelpers/addSpecificFlags.cmake @@ -0,0 +1,112 @@ +cmake_minimum_required(VERSION 2.8) + +if(POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) +endif() + +add_compiler_flag("-Wall") + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") +#gcc/clang compiler flags + if(NOT "SX_PEDANTIC" STREQUAL "OFF") + add_compiler_flag("-pedantic") + endif() + + if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") + add_compiler_flag("-g") + endif() + + if("${CPP_VERSION}" STREQUAL "03") + add_compiler_flag("-std=c++03") + add_compiler_flag("-D \"SX_CPP03_BOOST\"") + add_compiler_flag("-D \"SX_NO_VARIADIC_MACRO\"") + elseif("${CPP_VERSION}" STREQUAL "03") + add_compiler_flag("-std=c++14") + else() + add_compiler_flag("-std=c++11") + add_compiler_flag("-D \"SX_NO_STD_MAKE_UNIQUE\"") + endif() + +# platform + if( "${CMAKE_CXX_FLAGS}" STREQUAL "-m64" ) + add_compiler_flag("-m64") + message(STATUS "setting platform x64") + elseif("${CMAKE_CXX_FLAGS}" STREQUAL "-m32") + add_compiler_flag("-m32") + message(STATUS "setting platform x86") + endif() +endif() + + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + # Checks buffer security. + set(extra_flags "${extra_flags} /GS") + + #Sets output warning level. + set(extra_flags "${extra_flags} /W4") + + #Disable specific Warnings. + set(extra_flags "${extra_flags} /wd\"4127\" /wd\"4250\"") + + #Defines constants and macros. + set(extra_flags "${extra_flags} /D \"_CRT_SECURE_NO_WARNINGS\"") + + #Enables function-level linking. + set(extra_flags "${extra_flags} /Gy") + + #Specifies standard behaviour under /Ze. + set(extra_flags "${extra_flags} /Zc:wchar_t /Zc:inline") + + #Disable minimal rebuild. + set(extra_flags "${extra_flags} /Gm-") + + #Enables additional security features and warnings. + set(extra_flags "${extra_flags} /sdl") + + #Specifies floating-point behaviour. + set(extra_flags "${extra_flags} /fp:precise") + + #Multibyte character sets macro. + set(extra_flags "${extra_flags} /D \"_MBCS\"") + + #Enables you to provide internal compiler error (ICE) information directly to the Visual C++ team. + set(extra_flags "${extra_flags} /errorReport:prompt") + + #Treats warnings as errors. + if( "${MSVC_VERSION}" STRGREATER "1800" ) + set(extra_flags "${extra_flags} /WX") + #else( "${MSVC_VERSION}" STRLESS "1900" ) + else() + set(extra_flags "${extra_flags} /WX-") + endif() + + + #Generates intrinsic functions. + set(extra_flags "${extra_flags} /Oi") + + #Specifies the model of exception handling. + set(extra_flags "${extra_flags} /EHsc") + + #Creates an object file. + set(extra_flags "${extra_flags} /Fo") + + #Marks an executable as verified to be compatible with the Windows Data Execution Prevention feature. + #set(extra_flags "${extra_flags} /NXCOMPAT") + + + # for release + if( "${CMAKE_BUILD_TYPE}" STREQUAL "Release" ) + #Creates fast code. + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /PDB-") + + #Controls LINK optimizations. + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /OPT:REF /OPT:ICF") + + # for debug + elseif( "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" ) + #Creates a program database (PDB) file. + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /PDB") + endif() + +endif() \ No newline at end of file diff --git a/CMakeHelpers/addYasmineOptions.cmake b/CMakeHelpers/addYasmineOptions.cmake new file mode 100644 index 0000000..94749d0 --- /dev/null +++ b/CMakeHelpers/addYasmineOptions.cmake @@ -0,0 +1,53 @@ +cmake_minimum_required(VERSION 2.8) + +if(POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) +endif() + + +# yasmine's preprocessor definitions + + +set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") +if( "${Y_OPTIMIZE}" STREQUAL "SIZE" ) + set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SIZE\"") + message(STATUS "Optimizing for size.") +else() + set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SPEED\"") + message(STATUS "Optimizing for speed.") +endif() + + +option("SX_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") +if( "${SX_NO_LOGGING}" ) + set(extra_flags "${extra_flags} -D \"SX_NO_LOGGING\"") + message(STATUS "No logging used.") +else() + message(STATUS "Logger is used.") +endif() + + +option("SX_NO_STD_MAKE_UNIQUE" "When the standard make_unique is not available (e.g. no C++14 support), you have to define this preprocessor definition. A yasmine drop-in replacement template will be used instead then.") +if( "${SX_NO_STD_MAKE_UNIQUE}" ) + set(extra_flags "${extra_flags} -D \"SX_NO_STD_MAKE_UNIQUE\"") + message(STATUS "SX_NO_STD_MAKE_UNIQUE is defined.") +endif() + +option("Y_LEAN_AND_MEAN" "If you compile the library with Y_LEAN_AND_MEAN being defined or if you define the macro locally before including yasmine.hpp, all the state pseudostates and the asynchronous simple state (with the asynchronous behaviour) are excluded (i.e. those headers are not included). This can reduce compile time.") +if( "${Y_LEAN_AND_MEAN}" ) + set(extra_flags "${extra_flags} -D \"Y_LEAN_AND_MEAN\"") + message(STATUS "Y_LEAN_AND_MEAN is defined.") +endif() + +option("Y_PROFILER" "If Y_PROFILER is defined, the state machine will count the number of events that were processed. The user can query the counter by calling the 'get_number_of_processed_events' method.") +if( "${Y_PROFILER}" ) + set(extra_flags "${extra_flags} -D \"Y_PROFILER\"") + message(STATUS "Y_PROFILER is defined.") +endif() + +option("SX_GCC_EXPAND_TEMPLATE_PARAM_PACK_BUG" "Sets to use a workaround for bug in GCC with expansion of template parameter pack that appears in a lambda-expression (bug reported for GCC 4.8.4)") +if( "${SX_GCC_EXPAND_TEMPLATE_PARAM_PACK_BUG}" ) + set(extra_flags "${extra_flags} -D \"SX_GCC_EXPAND_TEMPLATE_PARAM_PACK_BUG\"") + message(STATUS "SX_GCC_EXPAND_TEMPLATE_PARAM_PACK_BUG is defined.") +endif() + diff --git a/CMakeHelpers/functions.cmake b/CMakeHelpers/functions.cmake new file mode 100644 index 0000000..5d9f343 --- /dev/null +++ b/CMakeHelpers/functions.cmake @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 2.8) + +if(POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) +endif() + + +function(use_pthread varName) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set(${varName} ${${varName}} pthread PARENT_SCOPE) + endif() +endfunction() + + +function(use_boost_libraries varName) + set(${varName} ${${varName}} ${Boost_LIBRARIES} PARENT_SCOPE) +endfunction() + + +function(add_library_for_linking varName libraryName) + set(${varName} ${${varName}} ${libraryName} PARENT_SCOPE) +endfunction() diff --git a/CMakeHelpers/functionsAddCompilerFlags.cmake b/CMakeHelpers/functionsAddCompilerFlags.cmake new file mode 100644 index 0000000..becdf2b --- /dev/null +++ b/CMakeHelpers/functionsAddCompilerFlags.cmake @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 2.8) + +include(CheckCXXCompilerFlag) + + +function(add_compiler_flag varFlag) + string(FIND "${CMAKE_CXX_FLAGS}" "${varFlag}" flag_already_set) + if(flag_already_set EQUAL -1) + check_cxx_compiler_flag("${varFlag}" flag_supported) + if(flag_supported) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${varFlag}" PARENT_SCOPE) + endif() + unset(flag_supported CACHE) + endif() +endfunction() diff --git a/CMakeHelpers/functionsRapidJSON.cmake b/CMakeHelpers/functionsRapidJSON.cmake new file mode 100644 index 0000000..5a73bcf --- /dev/null +++ b/CMakeHelpers/functionsRapidJSON.cmake @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 2.8) + +if(POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) +endif() + +function(use_rapid_JSON) +if(SX_RAPIDJSON) + message("SX_RAPIDJSON is set by user.") +else() + message("SX_RAPIDJSON is not set by user. Setting default value.") + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set(SX_RAPIDJSON "/usr/include/rapidjson") + elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + set(SX_RAPIDJSON "C:\\Program Files\\rapidjson") + endif() +endif() + +include_directories(${SX_RAPIDJSON}) + +message(STATUS "include rapidJSON from: ${SX_RAPIDJSON}") + +endfunction() diff --git a/CMakeHelpers/setVariables.cmake b/CMakeHelpers/setVariables.cmake new file mode 100644 index 0000000..8de4d4c --- /dev/null +++ b/CMakeHelpers/setVariables.cmake @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 2.8) + +if(POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) +endif() + + +if(("${Y_STATIC}" STREQUAL "ON") OR ("${SX_STATIC}" STREQUAL "ON")) + set(LINK_TYPE "STATIC") +else() + set(LINK_TYPE "SHARED") +endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a8248d..ff9ec7d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,28 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 2.8) project(yasmine) + + +set(CMAKE_VERBOSE_MAKEFILE, 1) + +if(POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) +endif() + +#set variables +include(./CMakeHelpers/setVariables.cmake) + +include(./CMakeHelpers/addBoost.cmake) + +include(./CMakeHelpers/functions.cmake) +include(./CMakeHelpers/functionsRapidJSON.cmake) +include(./CMakeHelpers/functionsAddCompilerFlags.cmake) + + add_subdirectory(libyasmine) add_subdirectory(yasmine_model) add_subdirectory(genesis) add_subdirectory(libygen) add_subdirectory(ygen) -add_subdirectory(examples) \ No newline at end of file +add_subdirectory(examples) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index d9ca196..363aea4 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 2.8) add_subdirectory(hello_yasmine) add_subdirectory(classic_farmroad) diff --git a/examples/classic_farmroad/CMakeLists.txt b/examples/classic_farmroad/CMakeLists.txt index ff71eb9..d9aa330 100644 --- a/examples/classic_farmroad/CMakeLists.txt +++ b/examples/classic_farmroad/CMakeLists.txt @@ -1,8 +1,10 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 2.8) project(classic_farmroad) -set(CMAKE_VERBOSE_MAKEFILE, 1) +if(POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) +endif() set(HEADER_FILES "./*.hpp" "./../../libyasmine/include/*.hpp" "./../../externals/essentials/include/essentials/*.hpp" "./../../externals/essentials/include/essentials/compatibility/*.hpp" "./../../externals/hermes/include/hermes/*.hpp") file(GLOB classic_farmroad_SRC "./*.cpp" ${HEADER_FILES}) @@ -11,178 +13,23 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) - -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if( "${CMAKE_CXX_FLAGS}" STREQUAL "-m64" ) - set(extra_flags "${extra_flags} -m64") - message(STATUS "setting platform x64") - elseif( "${CMAKE_CXX_FLAGS}" STREQUAL "-m32" ) - set(extra_flags "${extra_flags} -m32") - message(STATUS "setting platform x86") - endif() - - if("${CPP_VERSION}" STREQUAL "03") - set(extra_flags "${extra_flags} -std=c++03 -Wall -Wpedantic -g -Wno-unknown-pragmas -D \"SX_CPP03_BOOST\" -D \"SX_NO_VARIADIC_MACRO\"") - elseif("${CPP_VERSION}" STREQUAL "14") - set(extra_flags "${extra_flags} -std=c++14 -Wall -Wpedantic -g") - else() - set(extra_flags "${extra_flags} -std=c++11 -Wall -Wpedantic -g -D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - - # yasmine's preprocessor definitions - set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") - if( "${Y_OPTIMIZE}" STREQUAL "SIZE" ) - set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SIZE\"") - else() - set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SPEED\"") - endif() - - option("SX_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") - if( "${SX_NO_LOGGING}" ) - set(extra_flags "${extra_flags} -D \"SX_NO_LOGGING\"") - endif() - - option("SX_NO_STD_MAKE_UNIQUE" "When the standard make_unique is not available (e.g. no C++14 support), you have to define this preprocessor definition. A yasmine drop-in replacement template will be used instead then.") - if( "${SX_NO_STD_MAKE_UNIQUE}" ) - set(extra_flags "${extra_flags} -D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - - option("Y_LEAN_AND_MEAN" "If you compile the library with Y_LEAN_AND_MEAN being defined or if you define the macro locally before including yasmine.hpp, all the state pseudostates and the asynchronous simple state (with the asynchronous behavior) are excluded (i.e. those headers are not included). This can reduce compile time.") - if( "${Y_LEAN_AND_MEAN}" ) - set(extra_flags "${extra_flags} -D \"Y_LEAN_AND_MEAN\"") - endif() - - option("Y_PROFILER" "If Y_PROFILER is defined, the state machine will count the number of events that were processed. The user can query the counter by calling the 'get_number_of_processed_events' method.") - if( "${Y_PROFILER}" ) - set(extra_flags "${extra_flags} -D \"Y_PROFILER\"") - endif() - -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - # Checks buffer security. - set(extra_flags "${extra_flags} /GS") - - #Sets output warning level. - set(extra_flags "${extra_flags} /W4") - - #Disable specific Warnings. - set(extra_flags "${extra_flags} /wd\"4127\" /wd\"4250\"") - - #Defines constants and macros. - set(extra_flags "${extra_flags} /D \"_CRT_SECURE_NO_WARNINGS\"") - - #Enables function-level linking. - set(extra_flags "${extra_flags} /Gy") - - #Specifies standard behavior under /Ze. - set(extra_flags "${extra_flags} /Zc:wchar_t /Zc:inline") - - #Disable minimal rebuild. - set(extra_flags "${extra_flags} /Gm-") - - #Enables additional security features and warnings. - set(extra_flags "${extra_flags} /sdl") - - #Specifies floating-point behavior. - set(extra_flags "${extra_flags} /fp:precise") - - #Multibyte character sets macro. - set(extra_flags "${extra_flags} /D \"_MBCS\"") - - #Enables you to provide internal compiler error (ICE) information directly to the Visual C++ team. - set(extra_flags "${extra_flags} /errorReport:prompt") - - #Treats warnings as errors. - set(extra_flags "${extra_flags} /WX") - - #Generates intrinsic functions. - set(extra_flags "${extra_flags} /Oi") - - #Specifies the model of exception handling. - set(extra_flags "${extra_flags} /EHsc") - - #Creates an object file. - set(extra_flags "${extra_flags} /Fo") - - #Marks an executable as verified to be compatible with the Windows Data Execution Prevention feature. - #set(extra_flags "${extra_flags} /NXCOMPAT") - -# yasmine's preprocessor definitions - set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") - if( "${Y_OPTIMIZE}" STREQUAL "SIZE" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_OPTIMIZE_4_SIZE\"") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_OPTIMIZE_4_SPEED\"") - endif() - - option("SX_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") - if( "${SX_NO_LOGGING}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"SX_NO_LOGGING\"") - endif() - - option("SX_NO_STD_MAKE_UNIQUE" "When the standard make_unique is not available (e.g. no C++14 support), you have to define this preprocessor definition. A yasmine drop-in replacement template will be used instead then.") - if( "${SX_NO_STD_MAKE_UNIQUE}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - - option("Y_LEAN_AND_MEAN" "If you compile the library with Y_LEAN_AND_MEAN being defined or if you define the macro locally before including yasmine.hpp, all the state pseudostates and the asynchronous simple state (with the asynchronous behavior) are excluded (i.e. those headers are not included). This can reduce compile time.") - if( "${Y_LEAN_AND_MEAN}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_LEAN_AND_MEAN\"") - endif() - - option("Y_PROFILER" "If Y_PROFILER is defined, the state machine will count the number of events that were processed. The user can query the counter by calling the 'get_number_of_processed_events' method.") - if( "${Y_PROFILER}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_PROFILER\"") - endif() - - # for release - if( "${CMAKE_BUILD_TYPE}" STREQUAL "Release" ) - #Creates fast code. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2") - - #Controls LINK optimizations. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /OPT:REF /OPT:ICF") - - # for debug - elseif( "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" ) - #Creates a program database (PDB) file. - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /PDB") - endif() - -endif() - +include(./../../CMakeHelpers/addSpecificFlags.cmake) +include(./../../CMakeHelpers/addYasmineOptions.cmake) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${extra_flags}") add_executable(classic_farmroad ${classic_farmroad_SRC}) include_directories("./../../libyasmine/include" "./../../externals/essentials/include" "./../../externals/hermes/include") -#using boost -if("${CPP_VERSION}" STREQUAL "03") - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - link_directories("${Y_BOOST_LIB_PATH}") - endif() -endif() - +set(link_libraries_list "") -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if("${CPP_VERSION}" STREQUAL "03") - target_link_libraries (classic_farmroad LINK_PUBLIC libyasmine pthread boost_system boost_thread boost_chrono boost_random) - else() - target_link_libraries (classic_farmroad LINK_PUBLIC libyasmine pthread) - endif() -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - target_link_libraries (classic_farmroad LINK_PUBLIC libyasmine) +if("${CPP_VERSION}" STREQUAL "03") + use_boost_libraries(link_libraries_list) endif() - -if("${CPP_VERSION}" STREQUAL "03") - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - #SET(Boost_USE_STATIC_LIBS ON) - SET(BOOST_ROOT "${Y_BOOST_LIB_INCLUDE}") - SET(Boost_INCLUDE_DIRS "${Y_BOOST_LIB_INCLUDE}") - include_directories(${Boost_INCLUDE_DIRS}) - target_link_libraries(classic_farmroad LINK_PUBLIC ${Boost_LIBRARIES}) - endif() -endif() +use_pthread(link_libraries_list) +add_library_for_linking(link_libraries_list libyasmine) +message(STATUS "classic_farmroad linking to libraries: ${link_libraries_list}" ) +target_link_libraries(classic_farmroad LINK_PUBLIC ${link_libraries_list}) install(TARGETS classic_farmroad DESTINATION bin) diff --git a/examples/event_collector_example/CMakeLists.txt b/examples/event_collector_example/CMakeLists.txt index 4651152..7f7ca09 100644 --- a/examples/event_collector_example/CMakeLists.txt +++ b/examples/event_collector_example/CMakeLists.txt @@ -1,8 +1,10 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 2.8) project(event_collector_example) -set(CMAKE_VERBOSE_MAKEFILE, 1) +if(POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) +endif() set(HEADER_FILES "./*.hpp" "./../../libyasmine/include/*.hpp" "./../../externals/essentials/include/essentials/*.hpp" "./../../externals/essentials/include/compatibility/*.hpp" "./../../externals/hermes/include/hermes/*.hpp") file(GLOB event_collector_example_SRC "./*.cpp" ${HEADER_FILES}) @@ -11,178 +13,23 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) - -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if( "${CMAKE_CXX_FLAGS}" STREQUAL "-m64" ) - set(extra_flags "${extra_flags} -m64") - message(STATUS "setting platform x64") - elseif( "${CMAKE_CXX_FLAGS}" STREQUAL "-m32" ) - set(extra_flags "${extra_flags} -m32") - message(STATUS "setting platform x86") - endif() - - if("${CPP_VERSION}" STREQUAL "03") - set(extra_flags "${extra_flags} -std=c++03 -Wall -Wpedantic -g -Wno-unknown-pragmas -D \"SX_CPP03_BOOST\" -D \"SX_NO_VARIADIC_MACRO\"") - elseif("${CPP_VERSION}" STREQUAL "14") - set(extra_flags "${extra_flags} -std=c++14 -Wall -Wpedantic -g") - else() - set(extra_flags "${extra_flags} -std=c++11 -Wall -Wpedantic -g -D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - - # yasmine's preprocessor definitions - set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") - if( "${Y_OPTIMIZE}" STREQUAL "SIZE" ) - set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SIZE\"") - else() - set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SPEED\"") - endif() - - option("SX_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") - if( "${SX_NO_LOGGING}" ) - set(extra_flags "${extra_flags} -D \"SX_NO_LOGGING\"") - endif() - - option("SX_NO_STD_MAKE_UNIQUE" "When the standard make_unique is not available (e.g. no C++14 support), you have to define this preprocessor definition. A yasmine drop-in replacement template will be used instead then.") - if( "${SX_NO_STD_MAKE_UNIQUE}" ) - set(extra_flags "${extra_flags} -D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - - option("Y_LEAN_AND_MEAN" "If you compile the library with Y_LEAN_AND_MEAN being defined or if you define the macro locally before including yasmine.hpp, all the state pseudostates and the asynchronous simple state (with the asynchronous behavior) are excluded (i.e. those headers are not included). This can reduce compile time.") - if( "${Y_LEAN_AND_MEAN}" ) - set(extra_flags "${extra_flags} -D \"Y_LEAN_AND_MEAN\"") - endif() - - option("Y_PROFILER" "If Y_PROFILER is defined, the state machine will count the number of events that were processed. The user can query the counter by calling the 'get_number_of_processed_events' method.") - if( "${Y_PROFILER}" ) - set(extra_flags "${extra_flags} -D \"Y_PROFILER\"") - endif() - -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - # Checks buffer security. - set(extra_flags "${extra_flags} /GS") - - #Sets output warning level. - set(extra_flags "${extra_flags} /W4") - - #Disable specific Warnings. - set(extra_flags "${extra_flags} /wd\"4127\" /wd\"4250\"") - - #Defines constants and macros. - set(extra_flags "${extra_flags} /D \"_CRT_SECURE_NO_WARNINGS\"") - - #Enables function-level linking. - set(extra_flags "${extra_flags} /Gy") - - #Specifies standard behavior under /Ze. - set(extra_flags "${extra_flags} /Zc:wchar_t /Zc:inline") - - #Disable minimal rebuild. - set(extra_flags "${extra_flags} /Gm-") - - #Enables additional security features and warnings. - set(extra_flags "${extra_flags} /sdl") - - #Specifies floating-point behavior. - set(extra_flags "${extra_flags} /fp:precise") - - #Multibyte character sets macro. - set(extra_flags "${extra_flags} /D \"_MBCS\"") - - #Enables you to provide internal compiler error (ICE) information directly to the Visual C++ team. - set(extra_flags "${extra_flags} /errorReport:prompt") - - #Treats warnings as errors. - set(extra_flags "${extra_flags} /WX") - - #Generates intrinsic functions. - set(extra_flags "${extra_flags} /Oi") - - #Specifies the model of exception handling. - set(extra_flags "${extra_flags} /EHsc") - - #Creates an object file. - set(extra_flags "${extra_flags} /Fo") - - #Marks an executable as verified to be compatible with the Windows Data Execution Prevention feature. - #set(extra_flags "${extra_flags} /NXCOMPAT") - -# yasmine's preprocessor definitions - set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") - if( "${Y_OPTIMIZE}" STREQUAL "SIZE" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_OPTIMIZE_4_SIZE\"") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_OPTIMIZE_4_SPEED\"") - endif() - - option("SX_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") - if( "${SX_NO_LOGGING}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"SX_NO_LOGGING\"") - endif() - - option("SX_NO_STD_MAKE_UNIQUE" "When the standard make_unique is not available (e.g. no C++14 support), you have to define this preprocessor definition. A yasmine drop-in replacement template will be used instead then.") - if( "${SX_NO_STD_MAKE_UNIQUE}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - - option("Y_LEAN_AND_MEAN" "If you compile the library with Y_LEAN_AND_MEAN being defined or if you define the macro locally before including yasmine.hpp, all the state pseudostates and the asynchronous simple state (with the asynchronous behavior) are excluded (i.e. those headers are not included). This can reduce compile time.") - if( "${Y_LEAN_AND_MEAN}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_LEAN_AND_MEAN\"") - endif() - - option("Y_PROFILER" "If Y_PROFILER is defined, the state machine will count the number of events that were processed. The user can query the counter by calling the 'get_number_of_processed_events' method.") - if( "${Y_PROFILER}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_PROFILER\"") - endif() - - # for release - if( "${CMAKE_BUILD_TYPE}" STREQUAL "Release" ) - #Creates fast code. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2") - - #Controls LINK optimizations. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /OPT:REF /OPT:ICF") - - # for debug - elseif( "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" ) - #Creates a program database (PDB) file. - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /PDB") - endif() - -endif() - +include(./../../CMakeHelpers/addSpecificFlags.cmake) +include(./../../CMakeHelpers/addYasmineOptions.cmake) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${extra_flags}") add_executable(event_collector_example ${event_collector_example_SRC}) include_directories("./../../libyasmine/include" "./../../externals/essentials/include" "./../../externals/hermes/include") -#using boost -if("${CPP_VERSION}" STREQUAL "03") - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - link_directories("${Y_BOOST_LIB_PATH}") - endif() -endif() - +set(link_libraries_list "") -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if("${CPP_VERSION}" STREQUAL "03") - target_link_libraries (event_collector_example LINK_PUBLIC libyasmine pthread boost_system boost_thread boost_chrono) - else() - target_link_libraries (event_collector_example LINK_PUBLIC libyasmine pthread) - endif() -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - target_link_libraries (event_collector_example LINK_PUBLIC libyasmine) +if("${CPP_VERSION}" STREQUAL "03") + use_boost_libraries(link_libraries_list) endif() - -if("${CPP_VERSION}" STREQUAL "03") - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - #SET(Boost_USE_STATIC_LIBS ON) - SET(BOOST_ROOT "${Y_BOOST_LIB_INCLUDE}") - SET(Boost_INCLUDE_DIRS "${Y_BOOST_LIB_INCLUDE}") - include_directories(${Boost_INCLUDE_DIRS}) - target_link_libraries(event_collector_example LINK_PUBLIC ${Boost_LIBRARIES}) - endif() -endif() +use_pthread(link_libraries_list) +add_library_for_linking(link_libraries_list libyasmine) +message(STATUS "event_collector_example linking to libraries: ${link_libraries_list}" ) +target_link_libraries(event_collector_example LINK_PUBLIC ${link_libraries_list}) install(TARGETS event_collector_example DESTINATION bin) diff --git a/examples/events_with_parameters/CMakeLists.txt b/examples/events_with_parameters/CMakeLists.txt index 56e5a1d..1d6fe6c 100644 --- a/examples/events_with_parameters/CMakeLists.txt +++ b/examples/events_with_parameters/CMakeLists.txt @@ -1,8 +1,10 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 2.8) project(events_with_parameters) -set(CMAKE_VERBOSE_MAKEFILE, 1) +if(POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) +endif() set(HEADER_FILES "./*.hpp" "./../../libyasmine/include/*.hpp" "./../../externals/essentials/include/essentials/*.hpp" "./../../externals/essentials/include/compatibility/*.hpp" "./../../externals/hermes/include/hermes/*.hpp") file(GLOB events_with_parameters_SRC "./*.cpp" ${HEADER_FILES}) @@ -11,178 +13,23 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) - -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if( "${CMAKE_CXX_FLAGS}" STREQUAL "-m64" ) - set(extra_flags "${extra_flags} -m64") - message(STATUS "setting platform x64") - elseif( "${CMAKE_CXX_FLAGS}" STREQUAL "-m32" ) - set(extra_flags "${extra_flags} -m32") - message(STATUS "setting platform x86") - endif() - - if("${CPP_VERSION}" STREQUAL "03") - set(extra_flags "${extra_flags} -std=c++03 -Wall -Wpedantic -g -Wno-unknown-pragmas -D \"SX_CPP03_BOOST\" -D \"SX_NO_VARIADIC_MACRO\"") - elseif("${CPP_VERSION}" STREQUAL "14") - set(extra_flags "${extra_flags} -std=c++14 -Wall -Wpedantic -g") - else() - set(extra_flags "${extra_flags} -std=c++11 -Wall -Wpedantic -g -D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - - # yasmine's preprocessor definitions - set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") - if( "${Y_OPTIMIZE}" STREQUAL "SIZE" ) - set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SIZE\"") - else() - set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SPEED\"") - endif() - - option("SX_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") - if( "${SX_NO_LOGGING}" ) - set(extra_flags "${extra_flags} -D \"SX_NO_LOGGING\"") - endif() - - option("SX_NO_STD_MAKE_UNIQUE" "When the standard make_unique is not available (e.g. no C++14 support), you have to define this preprocessor definition. A yasmine drop-in replacement template will be used instead then.") - if( "${SX_NO_STD_MAKE_UNIQUE}" ) - set(extra_flags "${extra_flags} -D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - - option("Y_LEAN_AND_MEAN" "If you compile the library with Y_LEAN_AND_MEAN being defined or if you define the macro locally before including yasmine.hpp, all the state pseudostates and the asynchronous simple state (with the asynchronous behavior) are excluded (i.e. those headers are not included). This can reduce compile time.") - if( "${Y_LEAN_AND_MEAN}" ) - set(extra_flags "${extra_flags} -D \"Y_LEAN_AND_MEAN\"") - endif() - - option("Y_PROFILER" "If Y_PROFILER is defined, the state machine will count the number of events that were processed. The user can query the counter by calling the 'get_number_of_processed_events' method.") - if( "${Y_PROFILER}" ) - set(extra_flags "${extra_flags} -D \"Y_PROFILER\"") - endif() - -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - # Checks buffer security. - set(extra_flags "${extra_flags} /GS") - - #Sets output warning level. - set(extra_flags "${extra_flags} /W4") - - #Disable specific Warnings. - set(extra_flags "${extra_flags} /wd\"4127\" /wd\"4250\"") - - #Defines constants and macros. - set(extra_flags "${extra_flags} /D \"_CRT_SECURE_NO_WARNINGS\"") - - #Enables function-level linking. - set(extra_flags "${extra_flags} /Gy") - - #Specifies standard behavior under /Ze. - set(extra_flags "${extra_flags} /Zc:wchar_t /Zc:inline") - - #Disable minimal rebuild. - set(extra_flags "${extra_flags} /Gm-") - - #Enables additional security features and warnings. - set(extra_flags "${extra_flags} /sdl") - - #Specifies floating-point behavior. - set(extra_flags "${extra_flags} /fp:precise") - - #Multibyte character sets macro. - set(extra_flags "${extra_flags} /D \"_MBCS\"") - - #Enables you to provide internal compiler error (ICE) information directly to the Visual C++ team. - set(extra_flags "${extra_flags} /errorReport:prompt") - - #Treats warnings as errors. - set(extra_flags "${extra_flags} /WX") - - #Generates intrinsic functions. - set(extra_flags "${extra_flags} /Oi") - - #Specifies the model of exception handling. - set(extra_flags "${extra_flags} /EHsc") - - #Creates an object file. - set(extra_flags "${extra_flags} /Fo") - - #Marks an executable as verified to be compatible with the Windows Data Execution Prevention feature. - #set(extra_flags "${extra_flags} /NXCOMPAT") - -# yasmine's preprocessor definitions - set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") - if( "${Y_OPTIMIZE}" STREQUAL "SIZE" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_OPTIMIZE_4_SIZE\"") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_OPTIMIZE_4_SPEED\"") - endif() - - option("SX_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") - if( "${SX_NO_LOGGING}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"SX_NO_LOGGING\"") - endif() - - option("SX_NO_STD_MAKE_UNIQUE" "When the standard make_unique is not available (e.g. no C++14 support), you have to define this preprocessor definition. A yasmine drop-in replacement template will be used instead then.") - if( "${SX_NO_STD_MAKE_UNIQUE}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - - option("Y_LEAN_AND_MEAN" "If you compile the library with Y_LEAN_AND_MEAN being defined or if you define the macro locally before including yasmine.hpp, all the state pseudostates and the asynchronous simple state (with the asynchronous behavior) are excluded (i.e. those headers are not included). This can reduce compile time.") - if( "${Y_LEAN_AND_MEAN}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_LEAN_AND_MEAN\"") - endif() - - option("Y_PROFILER" "If Y_PROFILER is defined, the state machine will count the number of events that were processed. The user can query the counter by calling the 'get_number_of_processed_events' method.") - if( "${Y_PROFILER}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_PROFILER\"") - endif() - - # for release - if( "${CMAKE_BUILD_TYPE}" STREQUAL "Release" ) - #Creates fast code. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2") - - #Controls LINK optimizations. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /OPT:REF /OPT:ICF") - - # for debug - elseif( "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" ) - #Creates a program database (PDB) file. - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /PDB") - endif() - -endif() - +include(./../../CMakeHelpers/addSpecificFlags.cmake) +include(./../../CMakeHelpers/addYasmineOptions.cmake) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${extra_flags}") add_executable(events_with_parameters ${events_with_parameters_SRC}) include_directories("./../../libyasmine/include" "./../../externals/essentials/include" "./../../externals/hermes/include") -#using boost -if("${CPP_VERSION}" STREQUAL "03") - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - link_directories("${Y_BOOST_LIB_PATH}") - endif() -endif() - +set(link_libraries_list "") -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if("${CPP_VERSION}" STREQUAL "03") - target_link_libraries (events_with_parameters LINK_PUBLIC libyasmine pthread boost_system boost_thread boost_chrono) - else() - target_link_libraries (events_with_parameters LINK_PUBLIC libyasmine pthread) - endif() -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - target_link_libraries (events_with_parameters LINK_PUBLIC libyasmine) +if("${CPP_VERSION}" STREQUAL "03") + use_boost_libraries(link_libraries_list) endif() - -if("${CPP_VERSION}" STREQUAL "03") - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - #SET(Boost_USE_STATIC_LIBS ON) - SET(BOOST_ROOT "${Y_BOOST_LIB_INCLUDE}") - SET(Boost_INCLUDE_DIRS "${Y_BOOST_LIB_INCLUDE}") - include_directories(${Boost_INCLUDE_DIRS}) - target_link_libraries(events_with_parameters LINK_PUBLIC ${Boost_LIBRARIES}) - endif() -endif() +use_pthread(link_libraries_list) +add_library_for_linking(link_libraries_list libyasmine) +message(STATUS "events_with_parameters linking to libraries: ${link_libraries_list}" ) +target_link_libraries(events_with_parameters LINK_PUBLIC ${link_libraries_list}) install(TARGETS events_with_parameters DESTINATION bin) diff --git a/examples/forty_two/CMakeLists.txt b/examples/forty_two/CMakeLists.txt index a6eb0ee..a6c10a2 100644 --- a/examples/forty_two/CMakeLists.txt +++ b/examples/forty_two/CMakeLists.txt @@ -1,8 +1,10 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 2.8) project(forty_two) -set(CMAKE_VERBOSE_MAKEFILE, 1) +if(POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) +endif() set(HEADER_FILES "./*.hpp" "./../../libyasmine/include/*.hpp" "./../../externals/essentials/include/essentials/*.hpp" "./../../externals/essentials/include/compatibility/*.hpp" "./../../externals/hermes/include/hermes/*.hpp") file(GLOB forty_two_SRC "./*.cpp" ${HEADER_FILES}) @@ -11,178 +13,23 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) - -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if( "${CMAKE_CXX_FLAGS}" STREQUAL "-m64" ) - set(extra_flags "${extra_flags} -m64") - message(STATUS "setting platform x64") - elseif( "${CMAKE_CXX_FLAGS}" STREQUAL "-m32" ) - set(extra_flags "${extra_flags} -m32") - message(STATUS "setting platform x86") - endif() - - if("${CPP_VERSION}" STREQUAL "03") - set(extra_flags "${extra_flags} -std=c++03 -Wall -Wpedantic -g -Wno-unknown-pragmas -D \"SX_CPP03_BOOST\" -D \"SX_NO_VARIADIC_MACRO\"") - elseif("${CPP_VERSION}" STREQUAL "14") - set(extra_flags "${extra_flags} -std=c++14 -Wall -Wpedantic -g") - else() - set(extra_flags "${extra_flags} -std=c++11 -Wall -Wpedantic -g -D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - - # yasmine's preprocessor definitions - set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") - if( "${Y_OPTIMIZE}" STREQUAL "SIZE" ) - set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SIZE\"") - else() - set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SPEED\"") - endif() - - option("SX_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") - if( "${SX_NO_LOGGING}" ) - set(extra_flags "${extra_flags} -D \"SX_NO_LOGGING\"") - endif() - - option("SX_NO_STD_MAKE_UNIQUE" "When the standard make_unique is not available (e.g. no C++14 support), you have to define this preprocessor definition. A yasmine drop-in replacement template will be used instead then.") - if( "${SX_NO_STD_MAKE_UNIQUE}" ) - set(extra_flags "${extra_flags} -D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - - option("Y_LEAN_AND_MEAN" "If you compile the library with Y_LEAN_AND_MEAN being defined or if you define the macro locally before including yasmine.hpp, all the state pseudostates and the asynchronous simple state (with the asynchronous behavior) are excluded (i.e. those headers are not included). This can reduce compile time.") - if( "${Y_LEAN_AND_MEAN}" ) - set(extra_flags "${extra_flags} -D \"Y_LEAN_AND_MEAN\"") - endif() - - option("Y_PROFILER" "If Y_PROFILER is defined, the state machine will count the number of events that were processed. The user can query the counter by calling the 'get_number_of_processed_events' method.") - if( "${Y_PROFILER}" ) - set(extra_flags "${extra_flags} -D \"Y_PROFILER\"") - endif() - -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - # Checks buffer security. - set(extra_flags "${extra_flags} /GS") - - #Sets output warning level. - set(extra_flags "${extra_flags} /W4") - - #Disable specific Warnings. - set(extra_flags "${extra_flags} /wd\"4127\" /wd\"4250\"") - - #Defines constants and macros. - set(extra_flags "${extra_flags} /D \"_CRT_SECURE_NO_WARNINGS\"") - - #Enables function-level linking. - set(extra_flags "${extra_flags} /Gy") - - #Specifies standard behavior under /Ze. - set(extra_flags "${extra_flags} /Zc:wchar_t /Zc:inline") - - #Disable minimal rebuild. - set(extra_flags "${extra_flags} /Gm-") - - #Enables additional security features and warnings. - set(extra_flags "${extra_flags} /sdl") - - #Specifies floating-point behavior. - set(extra_flags "${extra_flags} /fp:precise") - - #Multibyte character sets macro. - set(extra_flags "${extra_flags} /D \"_MBCS\"") - - #Enables you to provide internal compiler error (ICE) information directly to the Visual C++ team. - set(extra_flags "${extra_flags} /errorReport:prompt") - - #Treats warnings as errors. - set(extra_flags "${extra_flags} /WX") - - #Generates intrinsic functions. - set(extra_flags "${extra_flags} /Oi") - - #Specifies the model of exception handling. - set(extra_flags "${extra_flags} /EHsc") - - #Creates an object file. - set(extra_flags "${extra_flags} /Fo") - - #Marks an executable as verified to be compatible with the Windows Data Execution Prevention feature. - #set(extra_flags "${extra_flags} /NXCOMPAT") - -# yasmine's preprocessor definitions - set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") - if( "${Y_OPTIMIZE}" STREQUAL "SIZE" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_OPTIMIZE_4_SIZE\"") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_OPTIMIZE_4_SPEED\"") - endif() - - option("SX_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") - if( "${SX_NO_LOGGING}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"SX_NO_LOGGING\"") - endif() - - option("SX_NO_STD_MAKE_UNIQUE" "When the standard make_unique is not available (e.g. no C++14 support), you have to define this preprocessor definition. A yasmine drop-in replacement template will be used instead then.") - if( "${SX_NO_STD_MAKE_UNIQUE}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - - option("Y_LEAN_AND_MEAN" "If you compile the library with Y_LEAN_AND_MEAN being defined or if you define the macro locally before including yasmine.hpp, all the state pseudostates and the asynchronous simple state (with the asynchronous behavior) are excluded (i.e. those headers are not included). This can reduce compile time.") - if( "${Y_LEAN_AND_MEAN}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_LEAN_AND_MEAN\"") - endif() - - option("Y_PROFILER" "If Y_PROFILER is defined, the state machine will count the number of events that were processed. The user can query the counter by calling the 'get_number_of_processed_events' method.") - if( "${Y_PROFILER}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_PROFILER\"") - endif() - - # for release - if( "${CMAKE_BUILD_TYPE}" STREQUAL "Release" ) - #Creates fast code. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2") - - #Controls LINK optimizations. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /OPT:REF /OPT:ICF") - - # for debug - elseif( "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" ) - #Creates a program database (PDB) file. - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /PDB") - endif() - -endif() - +include(./../../CMakeHelpers/addSpecificFlags.cmake) +include(./../../CMakeHelpers/addYasmineOptions.cmake) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${extra_flags}") add_executable(forty_two ${forty_two_SRC}) include_directories("./../../libyasmine/include" "./../../externals/essentials/include" "./../../externals/hermes/include") -#using boost -if("${CPP_VERSION}" STREQUAL "03") - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - link_directories("${Y_BOOST_LIB_PATH}") - endif() -endif() - +set(link_libraries_list "") -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if("${CPP_VERSION}" STREQUAL "03") - target_link_libraries (forty_two LINK_PUBLIC libyasmine pthread boost_system boost_thread boost_chrono) - else() - target_link_libraries (forty_two LINK_PUBLIC libyasmine pthread) - endif() -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - target_link_libraries (forty_two LINK_PUBLIC libyasmine) +if("${CPP_VERSION}" STREQUAL "03") + use_boost_libraries(link_libraries_list) endif() - -if("${CPP_VERSION}" STREQUAL "03") - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - #SET(Boost_USE_STATIC_LIBS ON) - SET(BOOST_ROOT "${Y_BOOST_LIB_INCLUDE}") - SET(Boost_INCLUDE_DIRS "${Y_BOOST_LIB_INCLUDE}") - include_directories(${Boost_INCLUDE_DIRS}) - target_link_libraries(forty_two LINK_PUBLIC ${Boost_LIBRARIES}) - endif() -endif() +use_pthread(link_libraries_list) +add_library_for_linking(link_libraries_list libyasmine) +message(STATUS "forty_two linking to libraries: ${link_libraries_list}" ) +target_link_libraries(forty_two LINK_PUBLIC ${link_libraries_list}) install(TARGETS forty_two DESTINATION bin) diff --git a/examples/forty_two/forty_two.cpp b/examples/forty_two/forty_two.cpp index 3e37029..7151409 100644 --- a/examples/forty_two/forty_two.cpp +++ b/examples/forty_two/forty_two.cpp @@ -12,7 +12,6 @@ #include "forty_two.hpp" #include -#include #include #ifdef Y_PROFILER @@ -405,10 +404,10 @@ void forty_two::run() state_machine_->halt(); SX_LOG( hermes::log_level::LL_INFO, "Run time: % seconds", - sxe::duration_cast< sxe::seconds >( stop - start ).count() ); + sxe::duration_cast< sxe::seconds >( stop - start ).count() ); #ifndef SX_NO_LOGGING - log_manager.halt_and_join(); + log_manager.halt_and_join(); #endif std::cin.get(); diff --git a/examples/forty_two/forty_two.hpp b/examples/forty_two/forty_two.hpp index f74eab2..f38657a 100644 --- a/examples/forty_two/forty_two.hpp +++ b/examples/forty_two/forty_two.hpp @@ -23,15 +23,15 @@ namespace examples class forty_two SX_FINAL -{ +{ public: typedef sxe::SX_UNIQUE_PTR state_machine_uptr; - + explicit forty_two( const sxe::uint32_t _max_iterations ); ~forty_two() SX_NOEXCEPT; - + private: state_machine_uptr build_state_machine(); bool check_state_machine() const; @@ -46,7 +46,7 @@ class forty_two SX_FINAL state_machine_uptr state_machine_; uint32_t iterations_; uint32_t max_iterations_; - + }; diff --git a/examples/generator_example/CMakeLists.txt b/examples/generator_example/CMakeLists.txt index 2d835e3..c2e9576 100644 --- a/examples/generator_example/CMakeLists.txt +++ b/examples/generator_example/CMakeLists.txt @@ -1,8 +1,10 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 2.8) project(generator_example) -set(CMAKE_VERBOSE_MAKEFILE, 1) +if(POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) +endif() set(HEADER_FILES "./*.hpp" "./../../libyasmine/include/*.hpp" "./../../externals/essentials/include/essentials/*.hpp" "./../../externals/essentials/include/compatibility/*.hpp" "./../../externals/hermes/include/hermes/*.hpp") file(GLOB generator_example_SRC "./*.cpp" ${HEADER_FILES}) @@ -11,176 +13,23 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) - -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if( "${CMAKE_CXX_FLAGS}" STREQUAL "-m64" ) - set(extra_flags "${extra_flags} -m64") - message(STATUS "setting platform x64") - elseif( "${CMAKE_CXX_FLAGS}" STREQUAL "-m32" ) - set(extra_flags "${extra_flags} -m32") - message(STATUS "setting platform x86") - endif() - - if("${CPP_VERSION}" STREQUAL "14") - set(extra_flags "${extra_flags} -std=c++14 -Wall -Wpedantic -g") - else() - set(extra_flags "${extra_flags} -std=c++11 -Wall -Wpedantic -g -D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - - # yasmine's preprocessor definitions - set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") - if( "${Y_OPTIMIZE}" STREQUAL "SIZE" ) - set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SIZE\"") - else() - set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SPEED\"") - endif() - - option("SX_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") - if( "${SX_NO_LOGGING}" ) - set(extra_flags "${extra_flags} -D \"SX_NO_LOGGING\"") - endif() - - option("SX_NO_STD_MAKE_UNIQUE" "When the standard make_unique is not available (e.g. no C++14 support), you have to define this preprocessor definition. A yasmine drop-in replacement template will be used instead then.") - if( "${SX_NO_STD_MAKE_UNIQUE}" ) - set(extra_flags "${extra_flags} -D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - - option("Y_LEAN_AND_MEAN" "If you compile the library with Y_LEAN_AND_MEAN being defined or if you define the macro locally before including yasmine.hpp, all the state pseudostates and the asynchronous simple state (with the asynchronous behavior) are excluded (i.e. those headers are not included). This can reduce compile time.") - if( "${Y_LEAN_AND_MEAN}" ) - set(extra_flags "${extra_flags} -D \"Y_LEAN_AND_MEAN\"") - endif() - - option("Y_PROFILER" "If Y_PROFILER is defined, the state machine will count the number of events that were processed. The user can query the counter by calling the 'get_number_of_processed_events' method.") - if( "${Y_PROFILER}" ) - set(extra_flags "${extra_flags} -D \"Y_PROFILER\"") - endif() - -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - # Checks buffer security. - set(extra_flags "${extra_flags} /GS") - - #Sets output warning level. - set(extra_flags "${extra_flags} /W4") - - #Disable specific Warnings. - set(extra_flags "${extra_flags} /wd\"4127\" /wd\"4250\"") - - #Defines constants and macros. - set(extra_flags "${extra_flags} /D \"_CRT_SECURE_NO_WARNINGS\"") - - #Enables function-level linking. - set(extra_flags "${extra_flags} /Gy") - - #Specifies standard behavior under /Ze. - set(extra_flags "${extra_flags} /Zc:wchar_t /Zc:inline") - - #Disable minimal rebuild. - set(extra_flags "${extra_flags} /Gm-") - - #Enables additional security features and warnings. - set(extra_flags "${extra_flags} /sdl") - - #Specifies floating-point behavior. - set(extra_flags "${extra_flags} /fp:precise") - - #Multibyte character sets macro. - set(extra_flags "${extra_flags} /D \"_MBCS\"") - - #Enables you to provide internal compiler error (ICE) information directly to the Visual C++ team. - set(extra_flags "${extra_flags} /errorReport:prompt") - - #Treats warnings as errors. - set(extra_flags "${extra_flags} /WX") - - #Generates intrinsic functions. - set(extra_flags "${extra_flags} /Oi") - - #Specifies the model of exception handling. - set(extra_flags "${extra_flags} /EHsc") - - #Creates an object file. - set(extra_flags "${extra_flags} /Fo") - - #Marks an executable as verified to be compatible with the Windows Data Execution Prevention feature. - #set(extra_flags "${extra_flags} /NXCOMPAT") - -# yasmine's preprocessor definitions - set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") - if( "${Y_OPTIMIZE}" STREQUAL "SIZE" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_OPTIMIZE_4_SIZE\"") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_OPTIMIZE_4_SPEED\"") - endif() - - option("SX_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") - if( "${SX_NO_LOGGING}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"SX_NO_LOGGING\"") - endif() - - option("SX_NO_STD_MAKE_UNIQUE" "When the standard make_unique is not available (e.g. no C++14 support), you have to define this preprocessor definition. A yasmine drop-in replacement template will be used instead then.") - if( "${SX_NO_STD_MAKE_UNIQUE}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - - option("Y_LEAN_AND_MEAN" "If you compile the library with Y_LEAN_AND_MEAN being defined or if you define the macro locally before including yasmine.hpp, all the state pseudostates and the asynchronous simple state (with the asynchronous behavior) are excluded (i.e. those headers are not included). This can reduce compile time.") - if( "${Y_LEAN_AND_MEAN}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_LEAN_AND_MEAN\"") - endif() - - option("Y_PROFILER" "If Y_PROFILER is defined, the state machine will count the number of events that were processed. The user can query the counter by calling the 'get_number_of_processed_events' method.") - if( "${Y_PROFILER}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_PROFILER\"") - endif() - - # for release - if( "${CMAKE_BUILD_TYPE}" STREQUAL "Release" ) - #Creates fast code. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2") - - #Controls LINK optimizations. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /OPT:REF /OPT:ICF") - - # for debug - elseif( "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" ) - #Creates a program database (PDB) file. - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /PDB") - endif() - -endif() - +include(./../../CMakeHelpers/addSpecificFlags.cmake) +include(./../../CMakeHelpers/addYasmineOptions.cmake) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${extra_flags}") add_executable(generator_example ${generator_example_SRC}) include_directories("./../../libyasmine/include" "./../../externals/essentials/include" "./../../externals/hermes/include") -#using boost -if("${CPP_VERSION}" STREQUAL "03") - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - link_directories("${Y_BOOST_LIB_PATH}") - endif() -endif() - +set(link_libraries_list "") -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if("${CPP_VERSION}" STREQUAL "03") - target_link_libraries (generator_example LINK_PUBLIC libyasmine pthread boost_system boost_thread boost_chrono) - else() - target_link_libraries (generator_example LINK_PUBLIC libyasmine pthread) - endif() -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - target_link_libraries (generator_example LINK_PUBLIC libyasmine) +if("${CPP_VERSION}" STREQUAL "03") + use_boost_libraries(link_libraries_list) endif() - -if("${CPP_VERSION}" STREQUAL "03") - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - #SET(Boost_USE_STATIC_LIBS ON) - SET(BOOST_ROOT "${Y_BOOST_LIB_INCLUDE}") - SET(Boost_INCLUDE_DIRS "${Y_BOOST_LIB_INCLUDE}") - include_directories(${Boost_INCLUDE_DIRS}) - target_link_libraries(generator_example LINK_PUBLIC ${Boost_LIBRARIES}) - endif() -endif() +use_pthread(link_libraries_list) +add_library_for_linking(link_libraries_list libyasmine) +message(STATUS "generator_example linking to libraries: ${link_libraries_list}" ) +target_link_libraries(generator_example LINK_PUBLIC ${link_libraries_list}) install(TARGETS generator_example DESTINATION bin) diff --git a/examples/hello_yasmine/CMakeLists.txt b/examples/hello_yasmine/CMakeLists.txt index 2005af4..c94626f 100644 --- a/examples/hello_yasmine/CMakeLists.txt +++ b/examples/hello_yasmine/CMakeLists.txt @@ -1,8 +1,10 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 2.8) project(hello_yasmine) -set(CMAKE_VERBOSE_MAKEFILE, 1) +if(POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) +endif() set(HEADER_FILES "./../../libyasmine/include/*.hpp" "./../../externals/essentials/include/essentials/*.hpp" "./../../externals/essentials/include/compatibility/*.hpp" "./../../externals/hermes/include/hermes/*.hpp") file(GLOB hello_yasmine_SRC "./*.cpp" ${HEADER_FILES}) @@ -11,178 +13,23 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) - -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if( "${CMAKE_CXX_FLAGS}" STREQUAL "-m64" ) - set(extra_flags "${extra_flags} -m64") - message(STATUS "setting platform x64") - elseif("${CMAKE_CXX_FLAGS}" STREQUAL "-m32") - set(extra_flags "${extra_flags} -m32") - message(STATUS "setting platform x86") - endif() - - if("${CPP_VERSION}" STREQUAL "03") - set(extra_flags "${extra_flags} -std=c++03 -Wall -Wpedantic -g -Wno-unknown-pragmas -D \"SX_CPP03_BOOST\" -D \"SX_NO_VARIADIC_MACRO\"") - elseif("${CPP_VERSION}" STREQUAL "14") - set(extra_flags "${extra_flags} -std=c++14 -Wall -Wpedantic -g") - else() - set(extra_flags "${extra_flags} -std=c++11 -Wall -Wpedantic -g -D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - - # yasmine's preprocessor definitions - set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") - if( "${Y_OPTIMIZE}" STREQUAL "SIZE" ) - set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SIZE\"") - else() - set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SPEED\"") - endif() - - option("SX_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") - if( "${SX_NO_LOGGING}" ) - set(extra_flags "${extra_flags} -D \"SX_NO_LOGGING\"") - endif() - - option("SX_NO_STD_MAKE_UNIQUE" "When the standard make_unique is not available (e.g. no C++14 support), you have to define this preprocessor definition. A yasmine drop-in replacement template will be used instead then.") - if( "${SX_NO_STD_MAKE_UNIQUE}" ) - set(extra_flags "${extra_flags} -D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - - option("Y_LEAN_AND_MEAN" "If you compile the library with Y_LEAN_AND_MEAN being defined or if you define the macro locally before including yasmine.hpp, all the state pseudostates and the asynchronous simple state (with the asynchronous behavior) are excluded (i.e. those headers are not included). This can reduce compile time.") - if( "${Y_LEAN_AND_MEAN}" ) - set(extra_flags "${extra_flags} -D \"Y_LEAN_AND_MEAN\"") - endif() - - option("Y_PROFILER" "If Y_PROFILER is defined, the state machine will count the number of events that were processed. The user can query the counter by calling the 'get_number_of_processed_events' method.") - if( "${Y_PROFILER}" ) - set(extra_flags "${extra_flags} -D \"Y_PROFILER\"") - endif() - -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - # Checks buffer security. - set(extra_flags "${extra_flags} /GS") - - #Sets output warning level. - set(extra_flags "${extra_flags} /W4") - - #Disable specific Warnings. - set(extra_flags "${extra_flags} /wd\"4127\" /wd\"4250\"") - - #Defines constants and macros. - set(extra_flags "${extra_flags} /D \"_CRT_SECURE_NO_WARNINGS\"") - - #Enables function-level linking. - set(extra_flags "${extra_flags} /Gy") - - #Specifies standard behavior under /Ze. - set(extra_flags "${extra_flags} /Zc:wchar_t /Zc:inline") - - #Disable minimal rebuild. - set(extra_flags "${extra_flags} /Gm-") - - #Enables additional security features and warnings. - set(extra_flags "${extra_flags} /sdl") - - #Specifies floating-point behavior. - set(extra_flags "${extra_flags} /fp:precise") - - #Multibyte character sets macro. - set(extra_flags "${extra_flags} /D \"_MBCS\"") - - #Enables you to provide internal compiler error (ICE) information directly to the Visual C++ team. - set(extra_flags "${extra_flags} /errorReport:prompt") - - #Treats warnings as errors. - set(extra_flags "${extra_flags} /WX") - - #Generates intrinsic functions. - set(extra_flags "${extra_flags} /Oi") - - #Specifies the model of exception handling. - set(extra_flags "${extra_flags} /EHsc") - - #Creates an object file. - set(extra_flags "${extra_flags} /Fo") - - #Marks an executable as verified to be compatible with the Windows Data Execution Prevention feature. - #set(extra_flags "${extra_flags} /NXCOMPAT") - -# yasmine's preprocessor definitions - set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") - if( "${Y_OPTIMIZE}" STREQUAL "SIZE" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_OPTIMIZE_4_SIZE\"") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_OPTIMIZE_4_SPEED\"") - endif() - - option("SX_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") - if( "${SX_NO_LOGGING}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"SX_NO_LOGGING\"") - endif() - - option("SX_NO_STD_MAKE_UNIQUE" "When the standard make_unique is not available (e.g. no C++14 support), you have to define this preprocessor definition. A yasmine drop-in replacement template will be used instead then.") - if( "${SX_NO_STD_MAKE_UNIQUE}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - - option("Y_LEAN_AND_MEAN" "If you compile the library with Y_LEAN_AND_MEAN being defined or if you define the macro locally before including yasmine.hpp, all the state pseudostates and the asynchronous simple state (with the asynchronous behavior) are excluded (i.e. those headers are not included). This can reduce compile time.") - if( "${Y_LEAN_AND_MEAN}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_LEAN_AND_MEAN\"") - endif() - - option("Y_PROFILER" "If Y_PROFILER is defined, the state machine will count the number of events that were processed. The user can query the counter by calling the 'get_number_of_processed_events' method.") - if( "${Y_PROFILER}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_PROFILER\"") - endif() - - # for release - if( "${CMAKE_BUILD_TYPE}" STREQUAL "Release" ) - #Creates fast code. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2") - - #Controls LINK optimizations. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /OPT:REF /OPT:ICF") - - # for debug - elseif( "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" ) - #Creates a program database (PDB) file. - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /PDB") - endif() - -endif() - +include(./../../CMakeHelpers/addSpecificFlags.cmake) +include(./../../CMakeHelpers/addYasmineOptions.cmake) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${extra_flags}") add_executable(hello_yasmine ${hello_yasmine_SRC}) include_directories("./../../libyasmine/include" "./../../externals/essentials/include" "./../../externals/hermes/include") -#using boost -if("${CPP_VERSION}" STREQUAL "03") - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - link_directories("${Y_BOOST_LIB_PATH}") - endif() -endif() - +set(link_libraries_list "") -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if("${CPP_VERSION}" STREQUAL "03") - target_link_libraries (hello_yasmine LINK_PUBLIC libyasmine pthread boost_system boost_thread boost_chrono) - else() - target_link_libraries (hello_yasmine LINK_PUBLIC libyasmine pthread) - endif() -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - target_link_libraries (hello_yasmine LINK_PUBLIC libyasmine) +if("${CPP_VERSION}" STREQUAL "03") + use_boost_libraries(link_libraries_list) endif() - -if("${CPP_VERSION}" STREQUAL "03") - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - #SET(Boost_USE_STATIC_LIBS ON) - SET(BOOST_ROOT "${Y_BOOST_LIB_INCLUDE}") - SET(Boost_INCLUDE_DIRS "${Y_BOOST_LIB_INCLUDE}") - include_directories(${Boost_INCLUDE_DIRS}) - target_link_libraries(hello_yasmine LINK_PUBLIC ${Boost_LIBRARIES}) - endif() -endif() +use_pthread(link_libraries_list) +add_library_for_linking(link_libraries_list libyasmine) +message(STATUS "hello_yasmine linking to libraries: ${link_libraries_list}" ) +target_link_libraries(hello_yasmine LINK_PUBLIC ${link_libraries_list}) install(TARGETS hello_yasmine DESTINATION bin) diff --git a/examples/substatemachines_and_variables/CMakeLists.txt b/examples/substatemachines_and_variables/CMakeLists.txt index 37fcf1a..e52d2d3 100644 --- a/examples/substatemachines_and_variables/CMakeLists.txt +++ b/examples/substatemachines_and_variables/CMakeLists.txt @@ -1,8 +1,10 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 2.8) project(substatemachines_and_variables) -set(CMAKE_VERBOSE_MAKEFILE, 1) +if(POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) +endif() set(HEADER_FILES "./*.hpp" "./../../libyasmine/include/*.hpp" "./../../externals/essentials/include/essentials/*.hpp" "./../../externals/essentials/include/compatibility/*.hpp" "./../../externals/hermes/include/hermes/*.hpp") file(GLOB substatemachines_and_variables_SRC "./*.cpp" ${HEADER_FILES}) @@ -11,178 +13,23 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) - -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if( "${CMAKE_CXX_FLAGS}" STREQUAL "-m64" ) - set(extra_flags "${extra_flags} -m64") - message(STATUS "setting platform x64") - elseif( "${CMAKE_CXX_FLAGS}" STREQUAL "-m32" ) - set(extra_flags "${extra_flags} -m32") - message(STATUS "setting platform x86") - endif() - - if("${CPP_VERSION}" STREQUAL "03") - set(extra_flags "${extra_flags} -std=c++03 -Wall -Wpedantic -g -Wno-unknown-pragmas -D \"SX_CPP03_BOOST\" -D \"SX_NO_VARIADIC_MACRO\"") - elseif("${CPP_VERSION}" STREQUAL "14") - set(extra_flags "${extra_flags} -std=c++14 -Wall -Wpedantic -g") - else() - set(extra_flags "${extra_flags} -std=c++11 -Wall -Wpedantic -g -D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - - # yasmine's preprocessor definitions - set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") - if( "${Y_OPTIMIZE}" STREQUAL "SIZE" ) - set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SIZE\"") - else() - set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SPEED\"") - endif() - - option("SX_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") - if( "${SX_NO_LOGGING}" ) - set(extra_flags "${extra_flags} -D \"SX_NO_LOGGING\"") - endif() - - option("SX_NO_STD_MAKE_UNIQUE" "When the standard make_unique is not available (e.g. no C++14 support), you have to define this preprocessor definition. A yasmine drop-in replacement template will be used instead then.") - if( "${SX_NO_STD_MAKE_UNIQUE}" ) - set(extra_flags "${extra_flags} -D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - - option("Y_LEAN_AND_MEAN" "If you compile the library with Y_LEAN_AND_MEAN being defined or if you define the macro locally before including yasmine.hpp, all the state pseudostates and the asynchronous simple state (with the asynchronous behavior) are excluded (i.e. those headers are not included). This can reduce compile time.") - if( "${Y_LEAN_AND_MEAN}" ) - set(extra_flags "${extra_flags} -D \"Y_LEAN_AND_MEAN\"") - endif() - - option("Y_PROFILER" "If Y_PROFILER is defined, the state machine will count the number of events that were processed. The user can query the counter by calling the 'get_number_of_processed_events' method.") - if( "${Y_PROFILER}" ) - set(extra_flags "${extra_flags} -D \"Y_PROFILER\"") - endif() - -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - # Checks buffer security. - set(extra_flags "${extra_flags} /GS") - - #Sets output warning level. - set(extra_flags "${extra_flags} /W4") - - #Disable specific Warnings. - set(extra_flags "${extra_flags} /wd\"4127\" /wd\"4250\"") - - #Defines constants and macros. - set(extra_flags "${extra_flags} /D \"_CRT_SECURE_NO_WARNINGS\"") - - #Enables function-level linking. - set(extra_flags "${extra_flags} /Gy") - - #Specifies standard behavior under /Ze. - set(extra_flags "${extra_flags} /Zc:wchar_t /Zc:inline") - - #Disable minimal rebuild. - set(extra_flags "${extra_flags} /Gm-") - - #Enables additional security features and warnings. - set(extra_flags "${extra_flags} /sdl") - - #Specifies floating-point behavior. - set(extra_flags "${extra_flags} /fp:precise") - - #Multibyte character sets macro. - set(extra_flags "${extra_flags} /D \"_MBCS\"") - - #Enables you to provide internal compiler error (ICE) information directly to the Visual C++ team. - set(extra_flags "${extra_flags} /errorReport:prompt") - - #Treats warnings as errors. - set(extra_flags "${extra_flags} /WX") - - #Generates intrinsic functions. - set(extra_flags "${extra_flags} /Oi") - - #Specifies the model of exception handling. - set(extra_flags "${extra_flags} /EHsc") - - #Creates an object file. - set(extra_flags "${extra_flags} /Fo") - - #Marks an executable as verified to be compatible with the Windows Data Execution Prevention feature. - #set(extra_flags "${extra_flags} /NXCOMPAT") - -# yasmine's preprocessor definitions - set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") - if( "${Y_OPTIMIZE}" STREQUAL "SIZE" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_OPTIMIZE_4_SIZE\"") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_OPTIMIZE_4_SPEED\"") - endif() - - option("SX_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") - if( "${SX_NO_LOGGING}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"SX_NO_LOGGING\"") - endif() - - option("SX_NO_STD_MAKE_UNIQUE" "When the standard make_unique is not available (e.g. no C++14 support), you have to define this preprocessor definition. A yasmine drop-in replacement template will be used instead then.") - if( "${SX_NO_STD_MAKE_UNIQUE}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - - option("Y_LEAN_AND_MEAN" "If you compile the library with Y_LEAN_AND_MEAN being defined or if you define the macro locally before including yasmine.hpp, all the state pseudostates and the asynchronous simple state (with the asynchronous behavior) are excluded (i.e. those headers are not included). This can reduce compile time.") - if( "${Y_LEAN_AND_MEAN}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_LEAN_AND_MEAN\"") - endif() - - option("Y_PROFILER" "If Y_PROFILER is defined, the state machine will count the number of events that were processed. The user can query the counter by calling the 'get_number_of_processed_events' method.") - if( "${Y_PROFILER}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_PROFILER\"") - endif() - - # for release - if( "${CMAKE_BUILD_TYPE}" STREQUAL "Release" ) - #Creates fast code. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2") - - #Controls LINK optimizations. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /OPT:REF /OPT:ICF") - - # for debug - elseif( "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" ) - #Creates a program database (PDB) file. - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /PDB") - endif() - -endif() - +include(./../../CMakeHelpers/addSpecificFlags.cmake) +include(./../../CMakeHelpers/addYasmineOptions.cmake) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${extra_flags}") add_executable(substatemachines_and_variables ${substatemachines_and_variables_SRC}) include_directories("./../../libyasmine/include" "./../../externals/essentials/include" "./../../externals/hermes/include") -#using boost -if("${CPP_VERSION}" STREQUAL "03") - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - link_directories("${Y_BOOST_LIB_PATH}") - endif() -endif() - +set(link_libraries_list "") -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if("${CPP_VERSION}" STREQUAL "03") - target_link_libraries (substatemachines_and_variables LINK_PUBLIC libyasmine pthread boost_system boost_thread boost_chrono) - else() - target_link_libraries (substatemachines_and_variables LINK_PUBLIC libyasmine pthread) - endif() -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - target_link_libraries (substatemachines_and_variables LINK_PUBLIC libyasmine) +if("${CPP_VERSION}" STREQUAL "03") + use_boost_libraries(link_libraries_list) endif() - -if("${CPP_VERSION}" STREQUAL "03") - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - #SET(Boost_USE_STATIC_LIBS ON) - SET(BOOST_ROOT "${Y_BOOST_LIB_INCLUDE}") - SET(Boost_INCLUDE_DIRS "${Y_BOOST_LIB_INCLUDE}") - include_directories(${Boost_INCLUDE_DIRS}) - target_link_libraries(substatemachines_and_variables LINK_PUBLIC ${Boost_LIBRARIES}) - endif() -endif() +use_pthread(link_libraries_list) +add_library_for_linking(link_libraries_list libyasmine) +message(STATUS "substatemachines_and_variables linking to libraries: ${link_libraries_list}" ) +target_link_libraries(substatemachines_and_variables LINK_PUBLIC ${link_libraries_list}) install(TARGETS substatemachines_and_variables DESTINATION bin) diff --git a/examples/unhandled_event_handler_example/CMakeLists.txt b/examples/unhandled_event_handler_example/CMakeLists.txt index 8b21c7b..d124ea0 100644 --- a/examples/unhandled_event_handler_example/CMakeLists.txt +++ b/examples/unhandled_event_handler_example/CMakeLists.txt @@ -1,8 +1,10 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 2.8) project(unhandled_event_handler_example) -set(CMAKE_VERBOSE_MAKEFILE, 1) +if(POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) +endif() set(HEADER_FILES "./../../libyasmine/include/*.hpp" "./../../externals/essentials/include/essentials/*.hpp" "./../../externals/essentials/include/compatibility/*.hpp" "./../../externals/hermes/include/hermes/*.hpp") file(GLOB unhandled_event_handler_example_SRC "./*.cpp" ${HEADER_FILES}) @@ -11,178 +13,23 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) - -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if( "${CMAKE_CXX_FLAGS}" STREQUAL "-m64" ) - set(extra_flags "${extra_flags} -m64") - message(STATUS "setting platform x64") - elseif("${CMAKE_CXX_FLAGS}" STREQUAL "-m32") - set(extra_flags "${extra_flags} -m32") - message(STATUS "setting platform x86") - endif() - - if("${CPP_VERSION}" STREQUAL "03") - set(extra_flags "${extra_flags} -std=c++03 -Wall -Wpedantic -g -Wno-unknown-pragmas -D \"SX_CPP03_BOOST\" -D \"SX_NO_VARIADIC_MACRO\"") - elseif("${CPP_VERSION}" STREQUAL "14") - set(extra_flags "${extra_flags} -std=c++14 -Wall -Wpedantic -g") - else() - set(extra_flags "${extra_flags} -std=c++11 -Wall -Wpedantic -g -D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - - # yasmine's preprocessor definitions - set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") - if( "${Y_OPTIMIZE}" STREQUAL "SIZE" ) - set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SIZE\"") - else() - set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SPEED\"") - endif() - - option("SX_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") - if( "${SX_NO_LOGGING}" ) - set(extra_flags "${extra_flags} -D \"SX_NO_LOGGING\"") - endif() - - option("SX_NO_STD_MAKE_UNIQUE" "When the standard make_unique is not available (e.g. no C++14 support), you have to define this preprocessor definition. A yasmine drop-in replacement template will be used instead then.") - if( "${SX_NO_STD_MAKE_UNIQUE}" ) - set(extra_flags "${extra_flags} -D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - - option("Y_LEAN_AND_MEAN" "If you compile the library with Y_LEAN_AND_MEAN being defined or if you define the macro locally before including yasmine.hpp, all the state pseudostates and the asynchronous simple state (with the asynchronous behavior) are excluded (i.e. those headers are not included). This can reduce compile time.") - if( "${Y_LEAN_AND_MEAN}" ) - set(extra_flags "${extra_flags} -D \"Y_LEAN_AND_MEAN\"") - endif() - - option("Y_PROFILER" "If Y_PROFILER is defined, the state machine will count the number of events that were processed. The user can query the counter by calling the 'get_number_of_processed_events' method.") - if( "${Y_PROFILER}" ) - set(extra_flags "${extra_flags} -D \"Y_PROFILER\"") - endif() - -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - # Checks buffer security. - set(extra_flags "${extra_flags} /GS") - - #Sets output warning level. - set(extra_flags "${extra_flags} /W4") - - #Disable specific Warnings. - set(extra_flags "${extra_flags} /wd\"4127\" /wd\"4250\"") - - #Defines constants and macros. - set(extra_flags "${extra_flags} /D \"_CRT_SECURE_NO_WARNINGS\"") - - #Enables function-level linking. - set(extra_flags "${extra_flags} /Gy") - - #Specifies standard behavior under /Ze. - set(extra_flags "${extra_flags} /Zc:wchar_t /Zc:inline") - - #Disable minimal rebuild. - set(extra_flags "${extra_flags} /Gm-") - - #Enables additional security features and warnings. - set(extra_flags "${extra_flags} /sdl") - - #Specifies floating-point behavior. - set(extra_flags "${extra_flags} /fp:precise") - - #Multibyte character sets macro. - set(extra_flags "${extra_flags} /D \"_MBCS\"") - - #Enables you to provide internal compiler error (ICE) information directly to the Visual C++ team. - set(extra_flags "${extra_flags} /errorReport:prompt") - - #Treats warnings as errors. - set(extra_flags "${extra_flags} /WX") - - #Generates intrinsic functions. - set(extra_flags "${extra_flags} /Oi") - - #Specifies the model of exception handling. - set(extra_flags "${extra_flags} /EHsc") - - #Creates an object file. - set(extra_flags "${extra_flags} /Fo") - - #Marks an executable as verified to be compatible with the Windows Data Execution Prevention feature. - #set(extra_flags "${extra_flags} /NXCOMPAT") - -# yasmine's preprocessor definitions - set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") - if( "${Y_OPTIMIZE}" STREQUAL "SIZE" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_OPTIMIZE_4_SIZE\"") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_OPTIMIZE_4_SPEED\"") - endif() - - option("SX_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") - if( "${SX_NO_LOGGING}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"SX_NO_LOGGING\"") - endif() - - option("SX_NO_STD_MAKE_UNIQUE" "When the standard make_unique is not available (e.g. no C++14 support), you have to define this preprocessor definition. A yasmine drop-in replacement template will be used instead then.") - if( "${SX_NO_STD_MAKE_UNIQUE}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - - option("Y_LEAN_AND_MEAN" "If you compile the library with Y_LEAN_AND_MEAN being defined or if you define the macro locally before including yasmine.hpp, all the state pseudostates and the asynchronous simple state (with the asynchronous behavior) are excluded (i.e. those headers are not included). This can reduce compile time.") - if( "${Y_LEAN_AND_MEAN}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_LEAN_AND_MEAN\"") - endif() - - option("Y_PROFILER" "If Y_PROFILER is defined, the state machine will count the number of events that were processed. The user can query the counter by calling the 'get_number_of_processed_events' method.") - if( "${Y_PROFILER}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_PROFILER\"") - endif() - - # for release - if( "${CMAKE_BUILD_TYPE}" STREQUAL "Release" ) - #Creates fast code. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2") - - #Controls LINK optimizations. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /OPT:REF /OPT:ICF") - - # for debug - elseif( "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" ) - #Creates a program database (PDB) file. - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /PDB") - endif() - -endif() - +include(./../../CMakeHelpers/addSpecificFlags.cmake) +include(./../../CMakeHelpers/addYasmineOptions.cmake) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${extra_flags}") add_executable(unhandled_event_handler_example ${unhandled_event_handler_example_SRC}) include_directories("./../../libyasmine/include" "./../../externals/essentials/include" "./../../externals/hermes/include") -#using boost -if("${CPP_VERSION}" STREQUAL "03") - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - link_directories("${Y_BOOST_LIB_PATH}") - endif() -endif() - +set(link_libraries_list "") -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if("${CPP_VERSION}" STREQUAL "03") - target_link_libraries (unhandled_event_handler_example LINK_PUBLIC libyasmine pthread boost_system boost_thread boost_chrono) - else() - target_link_libraries (unhandled_event_handler_example LINK_PUBLIC libyasmine pthread) - endif() -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - target_link_libraries (unhandled_event_handler_example LINK_PUBLIC libyasmine) +if("${CPP_VERSION}" STREQUAL "03") + use_boost_libraries(link_libraries_list) endif() - -if("${CPP_VERSION}" STREQUAL "03") - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - #SET(Boost_USE_STATIC_LIBS ON) - SET(BOOST_ROOT "${Y_BOOST_LIB_INCLUDE}") - SET(Boost_INCLUDE_DIRS "${Y_BOOST_LIB_INCLUDE}") - include_directories(${Boost_INCLUDE_DIRS}) - target_link_libraries(unhandled_event_handler_example LINK_PUBLIC ${Boost_LIBRARIES}) - endif() -endif() +use_pthread(link_libraries_list) +add_library_for_linking(link_libraries_list libyasmine) +message(STATUS "unhandled_event_handler_example linking to libraries: ${link_libraries_list}" ) +target_link_libraries(unhandled_event_handler_example LINK_PUBLIC ${link_libraries_list}) install(TARGETS unhandled_event_handler_example DESTINATION bin) diff --git a/externals/essentials/include/essentials/compatibility/compatibility.hpp b/externals/essentials/include/essentials/compatibility/compatibility.hpp index 90ddb19..9116631 100644 --- a/externals/essentials/include/essentials/compatibility/compatibility.hpp +++ b/externals/essentials/include/essentials/compatibility/compatibility.hpp @@ -12,6 +12,9 @@ #define COMPATIBILITY_63A35CFD_26BC_42BE_9F09_D559349FFE63 +#include "essentials_backward_compatibility.hpp" + + #ifdef SX_CPP03_BOOST #ifdef _MSC_VER #pragma warning( push ) @@ -170,7 +173,7 @@ namespace sxe using std::remove_const; using std::random_device; - + #endif diff --git a/externals/essentials/include/essentials/compatibility/essentials_backward_compatibility.hpp b/externals/essentials/include/essentials/compatibility/essentials_backward_compatibility.hpp new file mode 100644 index 0000000..077dbb4 --- /dev/null +++ b/externals/essentials/include/essentials/compatibility/essentials_backward_compatibility.hpp @@ -0,0 +1,31 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex essentials library (http://essentials.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://essentials.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef ESSENTIALS_BACKWARD_COMPATIBILITY_EBFE3698_30C0_456A_A146_1F081011CB49 +#define ESSENTIALS_BACKWARD_COMPATIBILITY_EBFE3698_30C0_456A_A146_1F081011CB49 + + +#ifdef Y_NO_STD_MAKE_UNIQUE +#define SX_NO_STD_MAKE_UNIQUE +#endif + + +#ifdef Y_CPP03_BOOST +#define SX_CPP03_BOOST +#endif + + +#define Y_UNIQUE_PTR SX_UNIQUE_PTR +#define Y_MAKE_UNIQUE SX_MAKE_UNIQUE +#define Y_MAKE_SHARED SX_MAKE_SHARED +#define Y_UNUSED_PARAMETER SX_UNUSED_PARAMETER + + +#endif diff --git a/externals/essentials/include/essentials/sxprintf.hpp b/externals/essentials/include/essentials/sxprintf.hpp index cee4672..7cab8ca 100644 --- a/externals/essentials/include/essentials/sxprintf.hpp +++ b/externals/essentials/include/essentials/sxprintf.hpp @@ -31,7 +31,7 @@ namespace sxe #ifdef SX_CPP03_BOOST typedef boost::variant< bool, int, unsigned int, sxe::int8_t, sxe::uint8_t, sxe::uint16_t, sxe::uint32_t, - std::string, std::size_t, const char*, int_least64_t, double > value_type; + std::string, std::size_t, const char*, boost::int_least64_t, double > value_type; typedef std::vector< value_type > value_types; #endif @@ -82,7 +82,7 @@ void print_superfluous_parameters( std::ostream& _os, const value& _value ) _os << SUPERFLUOUS_PARAMETER_START; #ifndef SX_CPP03_BOOST stream_writer< value >::print( _os, _value ); -#else +#else print_value_type_value( _os, _value ); #endif _os << SUPERFLUOUS_PARAMETER_END; @@ -109,11 +109,11 @@ void print_superfluous_parameters( std::ostream& _os, #endif -void sxprintf( std::ostream& _os, const char* _format ); +void sxprintf( std::ostream& _os, const char* _format ); #ifndef SX_CPP03_BOOST template< typename value, typename ... args > -void sxprintf( std::ostream& _os, const char* _format, const value& _value, args ... _args ) +void sxprintf( std::ostream& _os, const char* _format, const value& _value, args ... _args ) { while( *_format ) { @@ -135,7 +135,7 @@ void sxprintf( std::ostream& _os, const char* _format, const value& _value, args if( format_settings.correct_ ) { _os << format_settings; - stream_writer< value >::print( _os, _value ); + stream_writer< value >::print( _os, _value ); } else { @@ -235,7 +235,7 @@ void sxprintf(std::ostream& _os, const char* const _format, const value_type& _v void sxprintf(std::ostream& _os, const char* const _format, const value_types& _values); #endif - + } diff --git a/externals/essentials/source/sxprintf.cpp b/externals/essentials/source/sxprintf.cpp index e5fc6b5..f3794a1 100644 --- a/externals/essentials/source/sxprintf.cpp +++ b/externals/essentials/source/sxprintf.cpp @@ -361,7 +361,7 @@ void sxprintf( std::ostream& _os, const char* const _format, const value_type& _ void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, - const value_type& _value3, const value_type& _value4 ) + const value_type& _value3, const value_type& _value4 ) { value_types values; values.push_back( _value1 ); @@ -372,8 +372,8 @@ void sxprintf( std::ostream& _os, const char* const _format, const value_type& _ } -void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, - const value_type& _value3, const value_type& _value4, const value_type& _value5 ) +void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, + const value_type& _value3, const value_type& _value4, const value_type& _value5 ) { value_types values; values.push_back( _value1 ); @@ -385,8 +385,8 @@ void sxprintf( std::ostream& _os, const char* const _format, const value_type& _ } -void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, - const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6 ) +void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, + const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6 ) { value_types values; values.push_back( _value1 ); @@ -399,8 +399,8 @@ void sxprintf( std::ostream& _os, const char* const _format, const value_type& _ } -void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, - const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6, +void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, + const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6, const value_type& _value7 ) { value_types values; @@ -415,9 +415,9 @@ void sxprintf( std::ostream& _os, const char* const _format, const value_type& _ } -void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, - const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6, - const value_type& _value7, const value_type& _value8 ) +void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, + const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6, + const value_type& _value7, const value_type& _value8 ) { value_types values; values.push_back( _value1 ); @@ -432,9 +432,9 @@ void sxprintf( std::ostream& _os, const char* const _format, const value_type& _ } -void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, - const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6, - const value_type& _value7, const value_type& _value8, const value_type& _value9 ) +void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, + const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6, + const value_type& _value7, const value_type& _value8, const value_type& _value9 ) { value_types values; values.push_back( _value1 ); @@ -450,9 +450,9 @@ void sxprintf( std::ostream& _os, const char* const _format, const value_type& _ } -void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, - const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6, - const value_type& _value7, const value_type& _value8, const value_type& _value9, const value_type& _value10 ) +void sxprintf( std::ostream& _os, const char* const _format, const value_type& _value1, const value_type& _value2, + const value_type& _value3, const value_type& _value4, const value_type& _value5, const value_type& _value6, + const value_type& _value7, const value_type& _value8, const value_type& _value9, const value_type& _value10 ) { value_types values; values.push_back( _value1 ); @@ -489,16 +489,16 @@ const char* sxprintf_impl( std::ostream& _os, const char* _format, value_types:: const sxe::format_settings format_settings = sxe::parse_format_string(&_format); const std::ios_base::fmtflags stream_flags = _os.flags(); const char streafill_ = _os.fill(); - _os << format_settings; + _os << format_settings; print_value_type_value( _os, *_position ); _os.flags(stream_flags); - _os.fill(streafill_); + _os.fill(streafill_); printed = true; if( !format_settings.missing_closing_bracket_ ) - { + { if( CLOSING_SQUARE_BRACKET == *( _format ) ) { - ++_format; + ++_format; } } else @@ -510,22 +510,22 @@ const char* sxprintf_impl( std::ostream& _os, const char* _format, value_types:: } } else - { + { print_value_type_value( _os, *_position ); printed = true; ++_format; break; - } + } if( _position + 1 != _end ) - { + { if( *_format != '\0' ) { ++_position; _format = sxprintf_impl( _os, _format, _position, _end, printed ); } - } - return( _format ); + } + return( _format ); } } else @@ -538,14 +538,14 @@ const char* sxprintf_impl( std::ostream& _os, const char* _format, value_types:: void sxprintf( std::ostream& _os, const char * const _format, const value_types& _values ) -{ +{ SX_ASSERT( _format, "No format string to parse was passed!" ); const char* current_position = _format; value_types::const_iterator _end = _values.end(); - value_types::const_iterator _position = _values.begin(); + value_types::const_iterator _position = _values.begin(); while( _position != _end ) - { + { bool printed = false; current_position = sxprintf_impl( _os, current_position, _position, _end, printed ); if( printed ) @@ -553,9 +553,9 @@ void sxprintf( std::ostream& _os, const char * const _format, const value_types& ++_position; } if( current_position[0] == '\0' ) - { + { break; - } + } } sxprintf( _os, current_position ); @@ -569,7 +569,7 @@ void sxprintf( std::ostream& _os, const char * const _format, const value_types& void print_value_type_value( std::ostream& _os, const value_type& _value ) { - const std::type_info& type_info = _value.type(); + const std::type_info& type_info = _value.type(); if( type_info == typeid ( bool ) ) { @@ -611,9 +611,9 @@ void print_value_type_value( std::ostream& _os, const value_type& _value ) { stream_writer< const char* >::print( _os, boost::get< const char* >( _value ) ); } - else if( type_info == typeid ( int_least64_t ) ) + else if( type_info == typeid ( boost::int_least64_t ) ) { - stream_writer< int_least64_t >::print( _os, boost::get< int_least64_t >( _value ) ); + stream_writer< boost::int_least64_t >::print( _os, boost::get< boost::int_least64_t >( _value ) ); } else if( type_info == typeid ( double ) ) { diff --git a/externals/hermes/include/hermes/color.hpp b/externals/hermes/include/hermes/color.hpp index 54a7248..085e25b 100644 --- a/externals/hermes/include/hermes/color.hpp +++ b/externals/hermes/include/hermes/color.hpp @@ -6,13 +6,14 @@ // The same information is available on the www @ http://hermes.seadex.de/License.html. // // // ////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef SX_NO_LOGGING #ifndef COLOR_63B5B1DB_D383_404D_93EF_AB2BC3A0D286 #define COLOR_63B5B1DB_D383_404D_93EF_AB2BC3A0D286 +#include "hermes_backward_compatibility.hpp" + +#ifndef SX_NO_LOGGING namespace hermes { @@ -54,7 +55,7 @@ namespace hermes //!\brief Constructor - //!\param _value Given color value that is represented by the structure. + //!\param _value Given color value that is represented by the structure. color( const inner _value ) : value_( _value ) { // Nothing to do... @@ -62,14 +63,14 @@ namespace hermes //!\brief Constructor - //!\param _color Given color structure containing the color that is represented by the structure. + //!\param _color Given color structure containing the color that is represented by the structure. color( const color& _color ) : value_( _color.value_ ) { // Nothing to do... } - //!\brief Get the color value represented by the structure. + //!\brief Get the color value represented by the structure. operator inner() const { return ( value_ ); diff --git a/externals/hermes/include/hermes/color_mapping.hpp b/externals/hermes/include/hermes/color_mapping.hpp index 229e883..12cd0eb 100644 --- a/externals/hermes/include/hermes/color_mapping.hpp +++ b/externals/hermes/include/hermes/color_mapping.hpp @@ -7,12 +7,15 @@ // // ////////////////////////////////////////////////////////////////////////////////////////////////////// -#ifndef SX_NO_LOGGING - #ifndef COLOR_MAPPING_A8F877D1_966B_463B_AE26_BD54CB2FEC35 #define COLOR_MAPPING_A8F877D1_966B_463B_AE26_BD54CB2FEC35 +#include "hermes_backward_compatibility.hpp" + + +#ifndef SX_NO_LOGGING + #include @@ -30,7 +33,7 @@ namespace hermes class color_mapping SX_FINAL { public: - //!\typedef color_map + //!\typedef color_map //!\brief Alias for the map of log levels to colors. typedef std::map< log_level, color > color_map; diff --git a/externals/hermes/include/hermes/cout_logger.hpp b/externals/hermes/include/hermes/cout_logger.hpp index 9dc5508..cd6d111 100644 --- a/externals/hermes/include/hermes/cout_logger.hpp +++ b/externals/hermes/include/hermes/cout_logger.hpp @@ -6,13 +6,16 @@ // The same information is available on the www @ http://hermes.seadex.de/License.html. // // // ////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef SX_NO_LOGGING #ifndef COUT_LOGGER_170B8470_DB09_43CF_A547_D6C928D5121F #define COUT_LOGGER_170B8470_DB09_43CF_A547_D6C928D5121F +#include "hermes_backward_compatibility.hpp" + + +#ifndef SX_NO_LOGGING + #include "logger.hpp" #include "color_mapping.hpp" diff --git a/externals/hermes/include/hermes/file_logger.hpp b/externals/hermes/include/hermes/file_logger.hpp index d0df092..f563a9c 100644 --- a/externals/hermes/include/hermes/file_logger.hpp +++ b/externals/hermes/include/hermes/file_logger.hpp @@ -7,13 +7,17 @@ // // ////////////////////////////////////////////////////////////////////////////////////////////////////// -#ifndef SX_NO_LOGGING - #ifndef FILE_LOGGER_0EE18DBE_D91D_407D_BF95_0EBC8A84EBD4 #define FILE_LOGGER_0EE18DBE_D91D_407D_BF95_0EBC8A84EBD4 +#include "hermes_backward_compatibility.hpp" + + +#ifndef SX_NO_LOGGING + + #include "logger.hpp" #include "essentials/exception_template.hpp" @@ -30,7 +34,7 @@ class file_logger: { public: //!\brief Exception class of the file_logger. - SX_EXCEPTION( exception ) + SX_EXCEPTION( exception ) //!\brief Constructor //!\param _max_file_size_in_bytes Maximum size of a log file in bytes. @@ -39,8 +43,8 @@ class file_logger: //!\param _name_extension The extension of the log files. //!\param _max_file_number The maximum number of log files. //!\param _throw_on_error Flag for throwing an exception on error. Default is true. - explicit file_logger( const size_t _max_file_size_in_bytes, const std::string& _log_files_directory, - const std::string& _name_suffix, const std::string& _name_extension, const unsigned _max_file_number, + explicit file_logger( const size_t _max_file_size_in_bytes, const std::string& _log_files_directory, + const std::string& _name_suffix, const std::string& _name_extension, const unsigned _max_file_number, const bool _throw_on_error = true ); virtual ~file_logger() SX_NOEXCEPT SX_OVERRIDE; SX_NO_COPY(file_logger) diff --git a/externals/hermes/include/hermes/hermes_backward_compatibility.hpp b/externals/hermes/include/hermes/hermes_backward_compatibility.hpp new file mode 100644 index 0000000..7780cd7 --- /dev/null +++ b/externals/hermes/include/hermes/hermes_backward_compatibility.hpp @@ -0,0 +1,29 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex hermes library (http://hermes.seadex.de). // +// Copyright( C ) 2017 Seadex GmbH // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://hermes.seadex.de/License.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef HERMES_BACKWARD_COMPATIBILITY_0C85D23F_60F8_43E6_A0AE_ABB9F0365630 +#define HERMES_BACKWARD_COMPATIBILITY_0C85D23F_60F8_43E6_A0AE_ABB9F0365630 + + +#ifdef Y_NO_LOGGING +#define SX_NO_LOGGING +#endif + + +#ifdef Y_NO_WINDOWS_H +#define SX_NO_WINDOWS_H +#endif + + +#define Y_LOG SX_LOG +#define Y_LOG_HEX SX_LOG_HEX + + +#endif diff --git a/externals/hermes/include/hermes/log.hpp b/externals/hermes/include/hermes/log.hpp index 5de53e2..0665dd7 100644 --- a/externals/hermes/include/hermes/log.hpp +++ b/externals/hermes/include/hermes/log.hpp @@ -11,6 +11,8 @@ #ifndef LOG_5AD3F1F5_0FC9_4D0E_8101_D9D70B8B1486 #define LOG_5AD3F1F5_0FC9_4D0E_8101_D9D70B8B1486 +#include "hermes_backward_compatibility.hpp" + #ifdef SX_NO_LOGGING @@ -33,7 +35,7 @@ void parameter_muncher( T, args ... _args ) //!\sa sxprintf #define SX_LOG( _dummy, ... ) \ do \ - { \ + {\ parameter_muncher( __VA_ARGS__ ); \ } \ while( false ) @@ -44,7 +46,7 @@ void parameter_muncher( T, args ... _args ) //!\sa sxprintf #define SX_LOG_HEX( _dummy, ... ) \ do \ - { \ + {\ parameter_muncher( __VA_ARGS__ ); \ } \ while( false ) diff --git a/externals/hermes/include/hermes/log_callback.hpp b/externals/hermes/include/hermes/log_callback.hpp index 4fd9f04..dae84de 100644 --- a/externals/hermes/include/hermes/log_callback.hpp +++ b/externals/hermes/include/hermes/log_callback.hpp @@ -7,12 +7,14 @@ // // ////////////////////////////////////////////////////////////////////////////////////////////////////// -#ifndef SX_NO_LOGGING - #ifndef LOG_CALLBACK_B451A9E6_FCDE_44DB_B821_5F838D942994 #define LOG_CALLBACK_B451A9E6_FCDE_44DB_B821_5F838D942994 +#include "hermes_backward_compatibility.hpp" + + +#ifndef SX_NO_LOGGING #include "essentials/compatibility/compatibility.hpp" @@ -20,7 +22,7 @@ namespace hermes { -//!\interface log_callback +//!\interface log_callback //!\brief Interface that adds wait functionality to the class that implements it. class log_callback { @@ -43,10 +45,10 @@ class log_callback //!\brief The thing we are waiting for is done. virtual void done() = 0; - //!\brief Checks the theing we are waiting for is done. + //!\brief Checks the thing we are waiting for is done. virtual bool is_done() = 0; }; - + } diff --git a/externals/hermes/include/hermes/log_level.hpp b/externals/hermes/include/hermes/log_level.hpp index c6da58b..07b05f8 100644 --- a/externals/hermes/include/hermes/log_level.hpp +++ b/externals/hermes/include/hermes/log_level.hpp @@ -8,12 +8,14 @@ ////////////////////////////////////////////////////////////////////////////////////////////////////// -#ifndef SX_NO_LOGGING - - #ifndef LOG_LEVEL_5059A1FA_DC2D_4C94_AA8B_49B750B30F07 #define LOG_LEVEL_5059A1FA_DC2D_4C94_AA8B_49B750B30F07 +#include "hermes_backward_compatibility.hpp" + + +#ifndef SX_NO_LOGGING + #include @@ -49,7 +51,7 @@ struct log_level //!\brief Constructor - //!\param _value Given log level value that is represented by the structure. + //!\param _value Given log level value that is represented by the structure. log_level( inner _value ) : value_( _value ) { // Nothing to do... @@ -64,7 +66,7 @@ struct log_level //!\brief Constructor - //!\param _color Given log level structure containing the log level value that is represented by the structure. + //!\param _color Given log level structure containing the log level value that is represented by the structure. log_level(const log_level& _log_level) : value_(_log_level.value_) { // Nothing to do... @@ -91,18 +93,17 @@ struct log_level //!\brief Convert the given log level to a string. //!\param _log_level The log level. //!\return The log level as string. -std::string log_level_to_string( const log_level _log_level ); +std::string log_level_to_string( const log_level _log_level ); #ifdef SX_CPP03_BOOST - + bool operator==( const hermes::log_level& _lhs, const hermes::log_level::inner _rhs ); bool operator==( const hermes::log_level::inner _lhs, const hermes::log_level& _rhs ); bool operator<(const hermes::log_level _lhs, const hermes::log_level _rhs); bool operator<=( const hermes::log_level _lhs, const hermes::log_level _rhs ); - #endif diff --git a/externals/hermes/include/hermes/log_manager_template.hpp b/externals/hermes/include/hermes/log_manager_template.hpp index 65dd14c..a080318 100644 --- a/externals/hermes/include/hermes/log_manager_template.hpp +++ b/externals/hermes/include/hermes/log_manager_template.hpp @@ -7,12 +7,15 @@ // // ////////////////////////////////////////////////////////////////////////////////////////////////////// -#ifndef SX_NO_LOGGING - #ifndef LOG_MANAGER_TEMPLATE_F6D33798_A43A_4C29_86F1_0FC821B92F9B #define LOG_MANAGER_TEMPLATE_F6D33798_A43A_4C29_86F1_0FC821B92F9B +#include "hermes_backward_compatibility.hpp" + + +#ifndef SX_NO_LOGGING + #include @@ -51,7 +54,7 @@ class log_manager_template SX_FINAL } - SX_NO_COPY(log_manager_template) + SX_NO_COPY(log_manager_template) //!\brief Get the currently set log level. //!\return Current log level. @@ -86,8 +89,8 @@ class log_manager_template SX_FINAL void log( const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, const std::string& _message, args ... _args ) { - { - log_message message( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str(), _args ... ) ); + { + log_message message( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str(), _args ... ) ); sxe::lock_guard< sxe::mutex > lock( mutex_ ); messages_.push( message ); } @@ -241,31 +244,31 @@ class log_manager_template SX_FINAL } - void log(const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + void log( const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, const std::string& _message, const sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6, const sxe::value_type& _value7, - const sxe::value_type& _value8, const sxe::value_type& _value9) + const sxe::value_type& _value8, const sxe::value_type& _value9 ) { { - log_message message( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf(_message.c_str(), _value1, _value2, - _value3, _value4, _value5, _value6, _value7, _value8, _value9) ); - sxe::lock_guard< sxe::mutex > lock(mutex_); - messages_.push(message); + log_message message( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str(), _value1, _value2, + _value3, _value4, _value5, _value6, _value7, _value8, _value9 ) ); + sxe::lock_guard< sxe::mutex > lock( mutex_ ); + messages_.push( message ); } condition_.notify_one(); - } + } - void log(const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, + void log( const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, const std::string& _message, const sxe::value_type& _value1, const sxe::value_type& _value2, const sxe::value_type& _value3, const sxe::value_type& _value4, const sxe::value_type& _value5, const sxe::value_type& _value6, const sxe::value_type& _value7, - const sxe::value_type& _value8, const sxe::value_type& _value9, const sxe::value_type& _value10) + const sxe::value_type& _value8, const sxe::value_type& _value9, const sxe::value_type& _value10 ) { { - log_message message( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf(_message.c_str(), _value1, _value2, - _value3, _value4, _value5, _value6, _value7, _value8, _value9, _value10) ); - sxe::lock_guard< sxe::mutex > lock(mutex_); - messages_.push(message); + log_message message( SX_NULLPTR, _log_level, _time_stamp, _file, _line, sxe::sxprintf( _message.c_str(), _value1, _value2, + _value3, _value4, _value5, _value6, _value7, _value8, _value9, _value10 ) ); + sxe::lock_guard< sxe::mutex > lock( mutex_ ); + messages_.push( message ); } condition_.notify_one(); } @@ -426,7 +429,7 @@ class log_manager_template SX_FINAL } condition_.notify_one(); waiter.wait(); - } + } void log_and_wait( const log_level _log_level, const std::string& _time_stamp, const std::string& _file, const int _line, @@ -462,7 +465,7 @@ class log_manager_template SX_FINAL //!\brief Starts the logging. On starting, a new thread is created which processes the enqueued log message by - //!sending them to each logger. The thread has to be stopped and joined before the log manager is destroyed! + //!sending them to each logger. The thread has to be stopped and joined before the log manager is destroyed! //!\return void //!\sa halt, join void run() diff --git a/externals/hermes/include/hermes/log_message.hpp b/externals/hermes/include/hermes/log_message.hpp index 34159c2..d0585c7 100644 --- a/externals/hermes/include/hermes/log_message.hpp +++ b/externals/hermes/include/hermes/log_message.hpp @@ -6,13 +6,16 @@ // The same information is available on the www @ http://hermes.seadex.de/License.html. // // // ////////////////////////////////////////////////////////////////////////////////////////////////////// - -#ifndef SX_NO_LOGGING #ifndef LOG_MESSAGE_2F81F136_9F98_4FE3_A47A_9DEBB9538995 #define LOG_MESSAGE_2F81F136_9F98_4FE3_A47A_9DEBB9538995 +#include "hermes_backward_compatibility.hpp" + + +#ifndef SX_NO_LOGGING + #include "log_level.hpp" #include "essentials/compatibility/compatibility.hpp" diff --git a/externals/hermes/include/hermes/logger.hpp b/externals/hermes/include/hermes/logger.hpp index b8e2267..362e79c 100644 --- a/externals/hermes/include/hermes/logger.hpp +++ b/externals/hermes/include/hermes/logger.hpp @@ -7,12 +7,15 @@ // // ////////////////////////////////////////////////////////////////////////////////////////////////////// -#ifndef SX_NO_LOGGING - #ifndef LOGGER_4207DA98_D8C1_41B4_B5B1_29E8C5A22DF3 #define LOGGER_4207DA98_D8C1_41B4_B5B1_29E8C5A22DF3 +#include "hermes_backward_compatibility.hpp" + + +#ifndef SX_NO_LOGGING + #include "logger_fwd.hpp" #include "essentials/non_copyable.hpp" @@ -43,7 +46,7 @@ class logger } - SX_NO_COPY(logger) + SX_NO_COPY(logger) //!\brief Log the message to the target medium. //!\param _log_message Message to be logged. diff --git a/externals/hermes/include/hermes/logger_fwd.hpp b/externals/hermes/include/hermes/logger_fwd.hpp index 3d86d91..2d7704c 100644 --- a/externals/hermes/include/hermes/logger_fwd.hpp +++ b/externals/hermes/include/hermes/logger_fwd.hpp @@ -7,14 +7,17 @@ // // ////////////////////////////////////////////////////////////////////////////////////////////////////// -#ifndef SX_NO_LOGGING - #ifndef LOGGER_FWD_9F0DC46E_91EC_44AB_ADE0_7F223D30DE83 #define LOGGER_FWD_9F0DC46E_91EC_44AB_ADE0_7F223D30DE83 +#include "hermes_backward_compatibility.hpp" + + +#ifndef SX_NO_LOGGING + -#include +#include #include "essentials/compatibility/compatibility.hpp" diff --git a/externals/hermes/include/hermes/std_timestamp_policy.hpp b/externals/hermes/include/hermes/std_timestamp_policy.hpp index 9ebc2e4..39eb9d6 100644 --- a/externals/hermes/include/hermes/std_timestamp_policy.hpp +++ b/externals/hermes/include/hermes/std_timestamp_policy.hpp @@ -7,12 +7,15 @@ // // ////////////////////////////////////////////////////////////////////////////////////////////////////// -#ifndef SX_NO_LOGGING - #ifndef STD_TIMESTAMP_POLICY_A0D64C16_D7D3_4E06_B647_F949D14BBBAB #define STD_TIMESTAMP_POLICY_A0D64C16_D7D3_4E06_B647_F949D14BBBAB +#include "hermes_backward_compatibility.hpp" + + +#ifndef SX_NO_LOGGING + #include diff --git a/externals/hermes/include/hermes/waiter.hpp b/externals/hermes/include/hermes/waiter.hpp index 04992ab..350920f 100644 --- a/externals/hermes/include/hermes/waiter.hpp +++ b/externals/hermes/include/hermes/waiter.hpp @@ -8,12 +8,14 @@ ////////////////////////////////////////////////////////////////////////////////////////////////////// -#ifndef SX_NO_LOGGING - - #ifndef WAITER_5E57D733_02DD_413D_A906_5047979A5DFD #define WAITER_5E57D733_02DD_413D_A906_5047979A5DFD +#include "hermes_backward_compatibility.hpp" + + +#ifndef SX_NO_LOGGING + #include "log_callback.hpp" #include "essentials/compatibility/thread.hpp" diff --git a/externals/hermes/source/color_mapping.cpp b/externals/hermes/source/color_mapping.cpp index 9e7a468..b290316 100644 --- a/externals/hermes/source/color_mapping.cpp +++ b/externals/hermes/source/color_mapping.cpp @@ -5,7 +5,7 @@ // Licensing information is available in the folder "license" which is part of this distribution. // // The same information is available on the www @ http://hermes.seadex.de/License.html. // // // -////////////////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////////////////// #ifndef SX_NO_LOGGING @@ -38,7 +38,7 @@ color_mapping::color_mapping() #else - color_mapping::color_mapping() + color_mapping::color_mapping() { color_map_[ log_level::LL_FATAL ] = color::C_RED; color_map_[ log_level::LL_ERROR ] = color::C_DARK_RED; @@ -48,7 +48,7 @@ color_mapping::color_mapping() color_map_[ log_level::LL_DEBUG ] = color::C_DARK_GREEN; color_map_[ log_level::LL_TRACE ] = color::C_DARK_GREEN; color_map_[ log_level::LL_SPAM ] = color::C_GREEN; - } + } #endif @@ -62,14 +62,14 @@ color_mapping::~color_mapping() SX_NOEXCEPT color color_mapping::get_color( const hermes::log_level _log_level ) const { - color color_to_use( color::C_WHITE ); + color color_to_use( color::C_WHITE ); color_map::const_iterator search = color_map_.find( _log_level ); if (search != color_map_.end()) { color_to_use = search->second; - } + } return( color_to_use ); -} +} } diff --git a/externals/hermes/source/log_message.cpp b/externals/hermes/source/log_message.cpp index 725e83b..9c859b6 100644 --- a/externals/hermes/source/log_message.cpp +++ b/externals/hermes/source/log_message.cpp @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////////////////////////////////////// #ifndef SX_NO_LOGGING - + #include "hermes/log_message.hpp" #include "hermes/log_callback.hpp" @@ -31,7 +31,7 @@ log_message::log_message() log_message::log_message( log_callback* _log_callback, const log_level _log_level, const std::string& _time_stamp, - const std::string& _file, const int _line, const std::string& _message ) + const std::string& _file, const int _line, const std::string& _message ) : log_level_( _log_level ), time_stamp_( _time_stamp ), file_( _file ), diff --git a/externals/hermes/source/std_timestamp_policy.cpp b/externals/hermes/source/std_timestamp_policy.cpp index 77c02f3..001eec9 100644 --- a/externals/hermes/source/std_timestamp_policy.cpp +++ b/externals/hermes/source/std_timestamp_policy.cpp @@ -42,11 +42,11 @@ std::string std_timestamp_policy::get_timestamp() { std::stringstream date_time_stream; time_t rawtime; - time( &rawtime ); - tm timeinfo = *localtime( &rawtime ); + time( &rawtime ); + tm timeinfo = *localtime( &rawtime ); date_time_stream << std::setfill( FILL_VALUE ) << std::setw( WIDTH_YEAR ) << ( YEAR_1900 + timeinfo.tm_year ) << DATE_DELIMITER << std::setfill( FILL_VALUE ) << std::setw( WIDTH_CLOCK ) << ++timeinfo.tm_mon << DATE_DELIMITER << - std::setfill( FILL_VALUE ) << std::setw( WIDTH_CLOCK ) << timeinfo.tm_mday << SPACE_SEPARATOR << std::setfill( FILL_VALUE ) << + std::setfill( FILL_VALUE ) << std::setw( WIDTH_CLOCK ) << timeinfo.tm_mday << SPACE_SEPARATOR << std::setfill( FILL_VALUE ) << std::setw( WIDTH_CLOCK ) << timeinfo.tm_hour << TIME_DELIMITER << std::setfill( FILL_VALUE ) << std::setw( WIDTH_CLOCK ) << timeinfo.tm_min << TIME_DELIMITER << std::setfill( FILL_VALUE ) << std::setw( WIDTH_CLOCK ) << timeinfo.tm_sec; diff --git a/externals/hermes/source/waiter.cpp b/externals/hermes/source/waiter.cpp index dd30cc9..ebd8498 100644 --- a/externals/hermes/source/waiter.cpp +++ b/externals/hermes/source/waiter.cpp @@ -34,7 +34,7 @@ waiter::~waiter() SX_NOEXCEPT void waiter::wait() { - sxe::unique_lock lock( done_mutex_ ); + sxe::unique_lock lock( done_mutex_ ); done_condition_variable_.wait( lock, sxe::bind( &waiter::is_done, this ) ); } diff --git a/genesis/CMakeLists.txt b/genesis/CMakeLists.txt index 0aedb19..ffff76e 100644 --- a/genesis/CMakeLists.txt +++ b/genesis/CMakeLists.txt @@ -1,8 +1,10 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 2.8) project(genesis) -set(CMAKE_VERBOSE_MAKEFILE, 1) +if(POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) +endif() file(GLOB genesis_SRC "include/*.hpp" "source/*.cpp") @@ -10,136 +12,8 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if( "${CMAKE_CXX_FLAGS}" STREQUAL "-m64" ) - set(extra_flags "${extra_flags} -m64") - message(STATUS "setting platform x64") - elseif("${CMAKE_CXX_FLAGS}" STREQUAL "-m32") - set(extra_flags "${extra_flags} -m32") - message(STATUS "setting platform x86") - endif() - - if("${CPP_VERSION}" STREQUAL "03") - set(extra_flags "${extra_flags} -std=c++03 -Wall -Wpedantic -g -Wno-unknown-pragmas -D \"SX_CPP03_BOOST\" -D \"SX_NO_VARIADIC_MACRO\"") - elseif("${CPP_VERSION}" STREQUAL "14") - set(extra_flags "${extra_flags} -std=c++14 -Wall -Wpedantic -g") - else() - set(extra_flags "${extra_flags} -std=c++11 -Wall -Wpedantic -g -D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - -# genesis's preprocessor definitions - set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") - if( "${Y_OPTIMIZE}" STREQUAL "SIZE" ) - set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SIZE\"") - message(STATUS "Optimizing for size.") - else() - set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SPEED\"") - message(STATUS "Optimizing for speed.") - endif() - - option("SX_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") - if( "${SX_NO_LOGGING}" ) - set(extra_flags "${extra_flags} -D \"SX_NO_LOGGING\"") - message(STATUS "No logging used.") - else() - message(STATUS "Logger is used.") - endif() - - option("SX_NO_STD_MAKE_UNIQUE" "When the standard make_unique is not available (e.g. no C++14 support), you have to define this preprocessor definition. A genesis drop-in replacement template will be used instead then.") - if( "${SX_NO_STD_MAKE_UNIQUE}" ) - set(extra_flags "${extra_flags} -D \"SX_NO_STD_MAKE_UNIQUE\"") - message(STATUS "SX_NO_STD_MAKE_UNIQUE is defined.") - endif() - - option("Y_LEAN_AND_MEAN" "If you compile the library with Y_LEAN_AND_MEAN being defined or if you define the macro locally before including genesis.hpp, all the state pseudostates and the asynchronous simple state (with the asynchronous behaviour) are excluded (i.e. those headers are not included). This can reduce compile time.") - if( "${Y_LEAN_AND_MEAN}" ) - set(extra_flags "${extra_flags} -D \"Y_LEAN_AND_MEAN\"") - message(STATUS "Y_LEAN_AND_MEAN is defined.") - endif() - - option("Y_PROFILER" "If Y_PROFILER is defined, the state machine will count the number of events that were processed. The user can query the counter by calling the 'get_number_of_processed_events' method.") - if( "${Y_PROFILER}" ) - set(extra_flags "${extra_flags} -D \"Y_PROFILER\"") - message(STATUS "Y_PROFILER is defined.") - endif() - - -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - # Checks buffer security. - set(extra_flags "${extra_flags} /GS") - - #Sets output warning level. - set(extra_flags "${extra_flags} /W4") - - #Disable specific Warnings. - set(extra_flags "${extra_flags} /wd\"4127\" /wd\"4250\"") - - #Defines constants and macros. - set(extra_flags "${extra_flags} /D \"_CRT_SECURE_NO_WARNINGS\"") - - #Enables function-level linking. - set(extra_flags "${extra_flags} /Gy") - - #Specifies standard behaviour under /Ze. - set(extra_flags "${extra_flags} /Zc:wchar_t /Zc:inline") - - #Disable minimal rebuild. - set(extra_flags "${extra_flags} /Gm-") - - #Enables additional security features and warnings. - set(extra_flags "${extra_flags} /sdl") - - #Specifies floating-point behaviour. - set(extra_flags "${extra_flags} /fp:precise") - - #Multibyte character sets macro. - set(extra_flags "${extra_flags} /D \"_MBCS\"") - - #Enables you to provide internal compiler error (ICE) information directly to the Visual C++ team. - set(extra_flags "${extra_flags} /errorReport:prompt") - - #Treats warnings as errors. - if( "${MSVC_VERSION}" STRGREATER "1800" ) - set(extra_flags "${extra_flags} /WX") - #else( "${MSVC_VERSION}" STRLESS "1900" ) - else() - set(extra_flags "${extra_flags} /WX-") - endif() - - - #Generates intrinsic functions. - set(extra_flags "${extra_flags} /Oi") - - #Specifies the model of exception handling. - set(extra_flags "${extra_flags} /EHsc") - - #Creates an object file. - set(extra_flags "${extra_flags} /Fo") - - # genesis's preprocessor definitions - - option("SX_NO_STD_MAKE_UNIQUE" "When the standard make_unique is not available (e.g. no C++14 support), you have to define this preprocessor definition. A genesis drop-in replacement template will be used instead then.") - if( "${SX_NO_STD_MAKE_UNIQUE}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"SX_NO_STD_MAKE_UNIQUE\"") - message(STATUS "SX_NO_STD_MAKE_UNIQUE is defined.") - endif() - - # for release - if( "${CMAKE_BUILD_TYPE}" STREQUAL "Release" ) - #Creates fast code. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /PDB-") - - #Controls LINK optimizations. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /OPT:REF /OPT:ICF") - - # for debug - elseif( "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" ) - #Creates a program database (PDB) file. - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /PDB") - endif() - -endif() +include(./../CMakeHelpers/addSpecificFlags.cmake) +include(./../CMakeHelpers/addYasmineOptions.cmake) include_directories("./include") include_directories("./../externals/essentials/include") @@ -148,13 +22,18 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${extra_flags}") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - add_library(libgenesis SHARED ${genesis_SRC}) + add_library(libgenesis ${LINK_TYPE} ${genesis_SRC}) elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") add_library(genesis STATIC ${genesis_SRC}) endif() - -install(TARGETS libgenesis DESTINATION lib) file(GLOB genesis_hpp "include/*.hpp") install(FILES ${genesis_hpp} DESTINATION include/genesis/include) -set_target_properties(libgenesis PROPERTIES PREFIX "") \ No newline at end of file + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + install(TARGETS libgenesis DESTINATION lib) + set_target_properties(libgenesis PROPERTIES PREFIX "") +elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + install(TARGETS genesis DESTINATION lib) + set_target_properties(genesis PROPERTIES PREFIX "") +endif() diff --git a/genesis/genesis.vcxproj b/genesis/genesis.vcxproj index 4dfd736..babd1f5 100644 --- a/genesis/genesis.vcxproj +++ b/genesis/genesis.vcxproj @@ -699,6 +699,7 @@ + diff --git a/genesis/genesis.vcxproj.filters b/genesis/genesis.vcxproj.filters index 1ae3d46..01f8b19 100644 --- a/genesis/genesis.vcxproj.filters +++ b/genesis/genesis.vcxproj.filters @@ -155,6 +155,9 @@ Header Files + + Header Files\external\essentials\compatibility + diff --git a/libyasmine/CMakeLists.txt b/libyasmine/CMakeLists.txt index 4143bb5..ec87305 100644 --- a/libyasmine/CMakeLists.txt +++ b/libyasmine/CMakeLists.txt @@ -1,202 +1,34 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 2.8) -project(libyasmine) +project(libyasmine CXX) set(CMAKE_VERBOSE_MAKEFILE, 1) +if(POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) +endif() + file(GLOB yasmine_SRC "include/*.hpp" "include_impl/*.hpp" "source/*.cpp" "../externals/essentials/include/essentials/*.hpp" "../externals/essentials/include/essentials/compatibility/*.hpp" "../externals/hermes/include/hermes/*.hpp" "../externals/essentials/source/*.cpp" "../externals/hermes/source/*.cpp") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if( "${CMAKE_CXX_FLAGS}" STREQUAL "-m64" ) - set(extra_flags "${extra_flags} -m64") - message(STATUS "setting platform x64") - elseif("${CMAKE_CXX_FLAGS}" STREQUAL "-m32") - set(extra_flags "${extra_flags} -m32") - message(STATUS "setting platform x86") - endif() - - if("${CPP_VERSION}" STREQUAL "03") - set(extra_flags "${extra_flags} -std=c++03 -Wall -Wpedantic -g -Wno-unknown-pragmas -D \"SX_CPP03_BOOST\" -D \"SX_NO_VARIADIC_MACRO\"") - elseif("${CPP_VERSION}" STREQUAL "14") - set(extra_flags "${extra_flags} -std=c++14 -Wall -Wpedantic -g") - else() - set(extra_flags "${extra_flags} -std=c++11 -Wall -Wpedantic -g -D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - -# yasmine's preprocessor definitions - set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") - if( "${Y_OPTIMIZE}" STREQUAL "SIZE" ) - set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SIZE\"") - message(STATUS "Optimizing for size.") - else() - set(extra_flags "${extra_flags} -D \"Y_OPTIMIZE_4_SPEED\"") - message(STATUS "Optimizing for speed.") - endif() - - option("SX_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") - if( "${SX_NO_LOGGING}" ) - set(extra_flags "${extra_flags} -D \"SX_NO_LOGGING\"") - message(STATUS "No logging used.") - else() - message(STATUS "Logger is used.") - endif() - - option("SX_NO_STD_MAKE_UNIQUE" "When the standard make_unique is not available (e.g. no C++14 support), you have to define this preprocessor definition. A yasmine drop-in replacement template will be used instead then.") - if( "${SX_NO_STD_MAKE_UNIQUE}" ) - set(extra_flags "${extra_flags} -D \"SX_NO_STD_MAKE_UNIQUE\"") - message(STATUS "SX_NO_STD_MAKE_UNIQUE is defined.") - endif() - - option("Y_LEAN_AND_MEAN" "If you compile the library with Y_LEAN_AND_MEAN being defined or if you define the macro locally before including yasmine.hpp, all the state pseudostates and the asynchronous simple state (with the asynchronous behaviour) are excluded (i.e. those headers are not included). This can reduce compile time.") - if( "${Y_LEAN_AND_MEAN}" ) - set(extra_flags "${extra_flags} -D \"Y_LEAN_AND_MEAN\"") - message(STATUS "Y_LEAN_AND_MEAN is defined.") - endif() - - option("Y_PROFILER" "If Y_PROFILER is defined, the state machine will count the number of events that were processed. The user can query the counter by calling the 'get_number_of_processed_events' method.") - if( "${Y_PROFILER}" ) - set(extra_flags "${extra_flags} -D \"Y_PROFILER\"") - message(STATUS "Y_PROFILER is defined.") - endif() - - option("SX_GCC_EXPAND_TEMPLATE_PARAM_PACK_BUG" "Sets to use a workaround for bug in GCC with expansion of template parameter pack that appears in a lambda-expression (bug reported for GCC 4.8.4)") - if( "${SX_GCC_EXPAND_TEMPLATE_PARAM_PACK_BUG}" ) - set(extra_flags "${extra_flags} -D \"SX_GCC_EXPAND_TEMPLATE_PARAM_PACK_BUG\"") - message(STATUS "SX_GCC_EXPAND_TEMPLATE_PARAM_PACK_BUG is defined.") - endif() - - -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - # Checks buffer security. - set(extra_flags "${extra_flags} /GS") - - #Sets output warning level. - set(extra_flags "${extra_flags} /W4") - - #Disable specific Warnings. - set(extra_flags "${extra_flags} /wd\"4127\" /wd\"4250\"") - - #Defines constants and macros. - set(extra_flags "${extra_flags} /D \"_CRT_SECURE_NO_WARNINGS\"") - - #Enables function-level linking. - set(extra_flags "${extra_flags} /Gy") - - #Specifies standard behaviour under /Ze. - set(extra_flags "${extra_flags} /Zc:wchar_t /Zc:inline") - - #Disable minimal rebuild. - set(extra_flags "${extra_flags} /Gm-") - - #Enables additional security features and warnings. - set(extra_flags "${extra_flags} /sdl") - - #Specifies floating-point behaviour. - set(extra_flags "${extra_flags} /fp:precise") - - #Multibyte character sets macro. - set(extra_flags "${extra_flags} /D \"_MBCS\"") - - #Enables you to provide internal compiler error (ICE) information directly to the Visual C++ team. - set(extra_flags "${extra_flags} /errorReport:prompt") - - #Treats warnings as errors. - if( "${MSVC_VERSION}" STRGREATER "1800" ) - set(extra_flags "${extra_flags} /WX") - #else( "${MSVC_VERSION}" STRLESS "1900" ) - else() - set(extra_flags "${extra_flags} /WX-") - endif() - - - #Generates intrinsic functions. - set(extra_flags "${extra_flags} /Oi") - - #Specifies the model of exception handling. - set(extra_flags "${extra_flags} /EHsc") - - #Creates an object file. - set(extra_flags "${extra_flags} /Fo") - - #Marks an executable as verified to be compatible with the Windows Data Execution Prevention feature. - #set(extra_flags "${extra_flags} /NXCOMPAT") - - # yasmine's preprocessor definitions - set(Y_OPTIMIZE "SPEED" CACHE STRING "Sets the optimize type. Supported values: SPEED and SIZE. Default value is SPEED.") - if( "${Y_OPTIMIZE}" STREQUAL "SIZE" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_OPTIMIZE_4_SIZE\"") - message(STATUS "Optimizing for size.") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_OPTIMIZE_4_SPEED\"") - message(STATUS "Optimizing for speed.") - endif() - - option("SX_NO_LOGGING" "Use when you want to use no logging at all (no logging code is created).") - if( "${SX_NO_LOGGING}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"SX_NO_LOGGING\"") - message(STATUS "No logging used.") - else() - message(STATUS "Logger is used.") - endif() - - option("SX_NO_STD_MAKE_UNIQUE" "When the standard make_unique is not available (e.g. no C++14 support), you have to define this preprocessor definition. A yasmine drop-in replacement template will be used instead then.") - if( "${SX_NO_STD_MAKE_UNIQUE}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"SX_NO_STD_MAKE_UNIQUE\"") - message(STATUS "SX_NO_STD_MAKE_UNIQUE is defined.") - endif() - - option("Y_LEAN_AND_MEAN" "If you compile the library with Y_LEAN_AND_MEAN being defined or if you define the macro locally before including yasmine.hpp, all the state pseudostates and the asynchronous simple state (with the asynchronous behaviour) are excluded (i.e. those headers are not included). This can reduce compile time.") - if( "${Y_LEAN_AND_MEAN}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_LEAN_AND_MEAN\"") - message(STATUS "Y_LEAN_AND_MEAN is defined.") - endif() - - option("Y_PROFILER" "If Y_PROFILER is defined, the state machine will count the number of events that were processed. The user can query the counter by calling the 'get_number_of_processed_events' method.") - if( "${Y_PROFILER}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"Y_PROFILER\"") - message(STATUS "Y_PROFILER is defined.") - endif() - - option("SX_GCC_EXPAND_TEMPLATE_PARAM_PACK_BUG" "Sets to use a workaround for bug in GCC with expansion of template parameter pack that appears in a lambda-expression (bug reported for GCC 4.8.4)") - if( "${SX_GCC_EXPAND_TEMPLATE_PARAM_PACK_BUG}" ) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"SX_GCC_EXPAND_TEMPLATE_PARAM_PACK_BUG\"") - message(STATUS "SX_GCC_EXPAND_TEMPLATE_PARAM_PACK_BUG is defined.") - endif() - - # for release - if( "${CMAKE_BUILD_TYPE}" STREQUAL "Release" ) - #Creates fast code. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /PDB-") - - #Controls LINK optimizations. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /OPT:REF /OPT:ICF") - - # for debug - elseif( "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" ) - #Creates a program database (PDB) file. - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /PDB") - endif() - -endif() - include_directories("./include" "./include_impl" "../externals/essentials/include" "../externals/hermes/include") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${extra_flags}") +include(./../CMakeHelpers/addSpecificFlags.cmake) +include(./../CMakeHelpers/addYasmineOptions.cmake) +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${extra_flags}") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - add_library(libyasmine SHARED ${yasmine_SRC}) + add_library(libyasmine ${LINK_TYPE} ${yasmine_SRC}) elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") add_library(libyasmine STATIC ${yasmine_SRC}) endif() SET_TARGET_PROPERTIES ( libyasmine PROPERTIES - VERSION 1.3.0 + VERSION 1.3.1 SOVERSION 1.3 ) install(TARGETS libyasmine DESTINATION lib) @@ -210,4 +42,4 @@ install(FILES ${yasmine_hpp_impl} DESTINATION include/yasmine/include_impl) install(FILES ${essentials_hpp} DESTINATION include/yasmine/essentials/include/essentials) install(FILES ${essentials_compatibility_hpp} DESTINATION include/yasmine/essentials/include/essentials/compatibility) install(FILES ${hermes_hpp} DESTINATION include/yasmine/hermes/include) -set_target_properties(libyasmine PROPERTIES PREFIX "") \ No newline at end of file +set_target_properties(libyasmine PROPERTIES PREFIX "") diff --git a/libyasmine/changelog.txt b/libyasmine/changelog.txt index 6e58d22..8f51511 100644 --- a/libyasmine/changelog.txt +++ b/libyasmine/changelog.txt @@ -2,6 +2,25 @@ All notable changes to this project are documented in this file. +##[1.3.1] - 2017-10-16 + +// TODO add te split of backward_compatibility.hpp + +### Added +• CMake: SX_STATIC flag to toggle library generation between static and shared. +• CMake: SX_PEDANTIC flag to turn off pedantic flag for gcc/clang compilers. +• SX_BOOST_LIB_INCLUDE and SX_BOOST_LIB_PATH for setting Boost headers and libraries paths. + +### Changed +• Use pragma warning just for Microsoft Visual Studio compiler. Removed -Wunknown-pragmas from CMake file. +• Y_BOOST_LIB_INCLUDE and Y_BOOST_LIB_PATH are deprecated. Use SX_BOOST_LIB_INCLUDE and SX_BOOST_LIB_PATH instead. +Y_BOOST_LIB_INCLUDE and Y_BOOST_LIB_PATH will still work. + +### Fixed +• sxprintf: added missing boost namespace +• bug: SX_UNUSED_PARAMETER incorrectly appearing in return of functions in assembly.hpp + + ##[1.3.0] - 2017-09-21 ### Changed diff --git a/libyasmine/include/assembly.hpp b/libyasmine/include/assembly.hpp index 8984c70..2d3f537 100644 --- a/libyasmine/include/assembly.hpp +++ b/libyasmine/include/assembly.hpp @@ -77,12 +77,12 @@ //!\brief Macro for using a class method as a guard. //!\deprecated USE Y_GUARD_METHOD2 instead. #define Y_GUARD_METHOD_SELECT_1( _method_name ) \ - sxy::constraint_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ return( SX_UNUSED_PARAMETER(_event_collector); this->_method_name( _event ) ); } ) + sxy::constraint_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event_collector); return( this->_method_name( _event ) ); } ) //!\brief Macro for using a class method as a guard. //!\deprecated USE Y_GUARD_METHOD2 instead. #define Y_GUARD_METHOD_SELECT_2( _class_name, _method_name ) \ - sxy::constraint_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ return( SX_UNUSED_PARAMETER(_event_collector); this->_method_name( _event ) ); } ) + sxy::constraint_function( [ this ]( const sxy::event& _event, sxy::event_collector& _event_collector ){ SX_UNUSED_PARAMETER(_event_collector); return( this->_method_name( _event ) ); } ) //!\brief Macro for using any type of action returning bool as a guard. #define Y_GUARD_ACTION_SELECT_1( _action ) \ @@ -105,7 +105,7 @@ //!\brief Macro for using a free function as a guard. //!\deprecated Use Y_GUARD_FUNCTION2 instead. #define Y_GUARD_FUNCTION( _function_name ) \ - sxy::constraint_function( []( const sxy::event& _event, sxy::event_collector& _event_collector )->bool { return( SX_UNUSED_PARAMETER(_event_collector); _function_name( _event ) ); } ) + sxy::constraint_function( []( const sxy::event& _event, sxy::event_collector& _event_collector )->bool { SX_UNUSED_PARAMETER(_event_collector); return( _function_name( _event ) ); } ) //!\brief Macro for using a free function as a guard without an event. //!\deprecated Use Y_GUARD_FUNCTION2 instead. @@ -137,7 +137,7 @@ //!\brief Macro for using a class method as a behavior without an event. #define Y_BEHAVIOR_METHOD_NO_EVENT_SELECT_2( _class_name, _method_name ) \ - sxy::behavior_function( sxe::bind( &_class_name::_method_name, this ) ) + sxy::behavior_function( sxe::bind( &_class_name::_method_name, this ) ) #define Y_GUARD_METHOD_SELECT_2( _class_name, _method_name ) \ sxy::constraint_function( sxe::bind( &_class_name::_method_name, this, sxe::_1 ) ) @@ -175,13 +175,13 @@ #ifndef SX_CPP03_BOOST // C++11 only - // Macros for passing handlers as behavior + // Macros for passing handlers as behavior //!\brief The macro creates a behavior_function for the specified method(s). //!\ The macro is variadic and can take up to 10 class methods pointers as parameters. //#define Y_BEHAVIOR_METHOD_EVENT(...) EXPAND( VA_SELECT( Y_BEHAVIOR_METHOD_EVENT_SELECT, __VA_ARGS__ ) ) #define Y_BEHAVIOR_METHOD_EVENT(...) EXPAND( Y_BEHAVIOR_METHOD2( this, __VA_ARGS__ ) ) - + //!\brief The macro creates a behavior_function for the specified function(s). //!\ The macro is variadic and can take up to 10 function pointers as parameters. #define Y_BEHAVIOR_FUNCTION_EVENT( ... ) EXPAND( Y_BEHAVIOR_FUNCTION2( __VA_ARGS__ ) ) diff --git a/libyasmine/include/libyasmine_backward_compatibility.hpp b/libyasmine/include/libyasmine_backward_compatibility.hpp new file mode 100644 index 0000000..7efb2fb --- /dev/null +++ b/libyasmine/include/libyasmine_backward_compatibility.hpp @@ -0,0 +1,44 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////// +// // +// This file is part of the Seadex yasmine ecosystem (http://yasmine.seadex.de). // +// Copyright (C) 2016-2017 Seadex GmbH // +// // +// Licensing information is available in the folder "license" which is part of this distribution. // +// The same information is available on the www @ http://yasmine.seadex.de/Licenses.html. // +// // +////////////////////////////////////////////////////////////////////////////////////////////////////// + + +#ifndef LIBYASMINE_BACKWARD_COMPATIBILITY_25EFEF99_3357_4F3D_843D_AEB2C56E19DD +#define LIBYASMINE_BACKWARD_COMPATIBILITY_25EFEF99_3357_4F3D_843D_AEB2C56E19DD + + +#include "essentials/compatibility/compatibility.hpp" + + +#ifdef Y_GCC_EXPAND_TEMPLATE_PARAM_PACK_BUG +#define SX_GCC_EXPAND_TEMPLATE_PARAM_PACK_BUG +#endif + + + +// TODO add to log as removed? +//#define Y_ASSERT SX_ASSERT +//#define Y_NULLPTR SX_NULLPTR +//#define Y_FOR SX_FOR +//#define Y_CONSTEXPR SX_CONSTEXPR +//#define Y_FINAL SX_FINAL +//#define Y_NOEXCEPT SX_NOEXCEPT +//#define Y_OVERRIDE SX_OVERRIDE +//#define Y_NO_COPY SX_NO_COPY +//#define Y_NO_COPY_OPERATOR_EQUAL SX_NO_ASSIGNMENT_OPERATOR + + + +namespace sxy +{ + using sxe::shared_ptr; +} + + +#endif diff --git a/libyasmine/include/utils.hpp b/libyasmine/include/utils.hpp index 93ac286..cf7cdba 100644 --- a/libyasmine/include/utils.hpp +++ b/libyasmine/include/utils.hpp @@ -13,6 +13,9 @@ #define UTILS_50FAC970_4B2B_46F8_91B8_16F5A7DC3D9B +#include "hermes/hermes_backward_compatibility.hpp" + + #ifdef WIN32 diff --git a/libyasmine/include/version.hpp b/libyasmine/include/version.hpp index e8e3071..b24934a 100644 --- a/libyasmine/include/version.hpp +++ b/libyasmine/include/version.hpp @@ -15,6 +15,7 @@ #include "essentials/base.hpp" #include "essentials/compatibility/compatibility.hpp" +#include "hermes/hermes_backward_compatibility.hpp" namespace sxy diff --git a/libyasmine/include/yasmine.hpp b/libyasmine/include/yasmine.hpp index 060648f..689d85c 100644 --- a/libyasmine/include/yasmine.hpp +++ b/libyasmine/include/yasmine.hpp @@ -12,7 +12,7 @@ #define YASMINE_2205A1D5_1962_477A_97DD_E8051B277A88 -#include "backward_compatibility.hpp" +#include "libyasmine_backward_compatibility.hpp" #include "essentials/compatibility/compatibility.hpp" #include "essentials/compatibility/chrono.hpp" diff --git a/libyasmine/include_impl/build_number.hpp b/libyasmine/include_impl/build_number.hpp index 2572ab2..9401703 100644 --- a/libyasmine/include_impl/build_number.hpp +++ b/libyasmine/include_impl/build_number.hpp @@ -24,7 +24,7 @@ namespace version { -const sxe::uint16_t BUILD_NUMBER( 751 ); +const sxe::uint16_t BUILD_NUMBER( 770 ); } diff --git a/libyasmine/libyasmine.vcxproj b/libyasmine/libyasmine.vcxproj index 006e5a5..de9da2a 100644 --- a/libyasmine/libyasmine.vcxproj +++ b/libyasmine/libyasmine.vcxproj @@ -87,6 +87,7 @@ + @@ -104,6 +105,7 @@ + @@ -129,7 +131,7 @@ - + diff --git a/libyasmine/libyasmine.vcxproj.filters b/libyasmine/libyasmine.vcxproj.filters index 16d3d2e..e5627cc 100644 --- a/libyasmine/libyasmine.vcxproj.filters +++ b/libyasmine/libyasmine.vcxproj.filters @@ -672,9 +672,6 @@ Headerdateien\external\hermes - - Headerdateien\infrastructure - Headerdateien\infrastructure @@ -693,6 +690,15 @@ Headerdateien\external\essentials + + Headerdateien\external\essentials\compatibility + + + Headerdateien\external\hermes + + + Headerdateien\infrastructure + diff --git a/libyasmine/source/choice_impl.cpp b/libyasmine/source/choice_impl.cpp index e1af185..d16339b 100644 --- a/libyasmine/source/choice_impl.cpp +++ b/libyasmine/source/choice_impl.cpp @@ -66,7 +66,7 @@ bool choice_impl::check( state_machine_defects& _defects ) const get_outgoing_transitions().size() ); SX_LOG( hermes::log_level::LL_SPAM, "Checking if choice '%' has more than one outgoing transition with no guard.", get_name() ); - uint8_t number_of_transitions_with_no_guard = 0; + sxe::uint8_t number_of_transitions_with_no_guard = 0; SX_FOR( const transition* const transition, get_outgoing_transitions() ) { diff --git a/libyasmine/source/transition_impl.cpp b/libyasmine/source/transition_impl.cpp index ee61892..235be5c 100644 --- a/libyasmine/source/transition_impl.cpp +++ b/libyasmine/source/transition_impl.cpp @@ -34,8 +34,10 @@ namespace sxy #ifdef SX_CPP03_BOOST -#pragma warning( push ) -#pragma warning( disable : 4100 ) + #ifdef _MSC_VER + #pragma warning( push ) + #pragma warning( disable : 4100 ) +#endif #endif @@ -97,12 +99,14 @@ transition_impl::transition_impl( const event_id _event_id, vertex& _source, ver #ifdef SX_CPP03_BOOST -#pragma warning( pop ) + #ifdef _MSC_VER + #pragma warning( pop ) + #endif #endif transition_impl::transition_impl( const event_ids _event_ids, vertex& _source, vertex& _target, - const sxy::transition_kind _kind, constraint_uptr _guard, behavior_uptr _behavior ) + const sxy::transition_kind _kind, constraint_uptr _guard, behavior_uptr _behavior ) : state_machine_element_impl( get_transition_name( _source, _target, _event_ids ) ), event_ids_( _event_ids ), source_( _source ), @@ -207,7 +211,7 @@ bool transition_impl::check_guard( const event& _event, event_collector& _event_ bool transition_impl::check( state_machine_defects& _defects ) const -{ +{ bool check_ok = check_for_cross_region_transition( _defects ); if( sxy::transition_kind::INTERNAL == get_kind() ) @@ -371,7 +375,7 @@ bool transition_impl::check_for_cross_region_transition( state_machine_defects& const vertex& target = get_target(); const region* const lca_of_source_target = source.LCA_region( target ); if( lca_of_source_target ) - { + { const raw_regions& source_ancestors = source.get_ancestors_as_regions(); raw_regions::const_iterator found_source_itr = std::find( source_ancestors.begin(), source_ancestors.end(), lca_of_source_target ); @@ -469,7 +473,7 @@ bool transition_impl::check_initial_pseudostate( state_machine_defects& _defects // Transition's source is a child of target's parent state or the parent state itself, when the target is an exit point. bool transition_impl::check_exit_point( state_machine_defects& _defects ) const { - bool check_ok = true; + bool check_ok = true; const exit_point* const target_exit_point = dynamic_cast< const exit_point* const >( &get_target() ); if( target_exit_point ) { diff --git a/libyasmine/source/version.cpp b/libyasmine/source/version.cpp index a7e6605..8170e04 100644 --- a/libyasmine/source/version.cpp +++ b/libyasmine/source/version.cpp @@ -28,7 +28,7 @@ namespace const sxe::uint16_t VERSION_MAJOR( 1 ); const sxe::uint16_t VERSION_MINOR( 3 ); -const sxe::uint16_t VERSION_PATCH( 0 ); +const sxe::uint16_t VERSION_PATCH( 1 ); } diff --git a/libygen/CMakeLists.txt b/libygen/CMakeLists.txt index e468a4b..bddd971 100644 --- a/libygen/CMakeLists.txt +++ b/libygen/CMakeLists.txt @@ -1,20 +1,12 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 2.8) project(libygen) -set(CMAKE_VERBOSE_MAKEFILE, 1) - -if(SX_RAPIDJSON) - message("SX_RAPIDJSON is set by user.") -else() - message("SX_RAPIDJSON is not set by user. Setting default value.") - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(SX_RAPIDJSON "/usr/include/rapidjson") - elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - set(SX_RAPIDJSON "C:\Program Files\rapidjson") - endif() +if(POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) endif() -message(STATUS ${SX_RAPIDJSON}) + +use_rapid_JSON() file(GLOB libygen_SRC "include/*.hpp" "source/*.cpp") @@ -22,68 +14,38 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if( "${CMAKE_CXX_FLAGS}" STREQUAL "-m64" ) - set(extra_flags "${extra_flags} -m64") - message(STATUS "setting platform x64") - elseif("${CMAKE_CXX_FLAGS}" STREQUAL "-m32") - set(extra_flags "${extra_flags} -m32") - message(STATUS "setting platform x86") - endif() - - - if("${CPP_VERSION}" STREQUAL "03") - set(extra_flags "${extra_flags} -std=c++03 -Wall -Wpedantic -g -Wno-unknown-pragmas -D \"SX_CPP03_BOOST\" -D \"SX_NO_VARIADIC_MACRO\"") - elseif("${CPP_VERSION}" STREQUAL "14") - set(extra_flags "${extra_flags} -std=c++14 -Wall -Wpedantic -g") - else() - set(extra_flags "${extra_flags} -std=c++11 -Wall -Wpedantic -g -D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - -endif() - -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - # for release - if( "${CMAKE_BUILD_TYPE}" STREQUAL "Release" ) - #Creates fast code. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /PDB-") - - #Controls LINK optimizations. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /OPT:REF /OPT:ICF") - - # for debug - elseif( "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" ) - #Creates a program database (PDB) file. - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /PDB") - endif() -endif() +include(./../CMakeHelpers/addSpecificFlags.cmake) +include(./../CMakeHelpers/addYasmineOptions.cmake) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${extra_flags}") include_directories("./include") -include_directories(${SX_RAPIDJSON}) include_directories("./../libyasmine" "./../genesis" "./../yasmine_model") include_directories("./../libyasmine/include" "./../genesis/include" "./../yasmine_model/include") include_directories("./../externals/essentials/include") + + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - add_library(libygen SHARED ${libygen_SRC}) + add_library(libygen ${LINK_TYPE} ${libygen_SRC}) elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") add_library(libygen STATIC ${libygen_SRC}) endif() -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if("${CPP_VERSION}" STREQUAL "03") - target_link_libraries (libygen LINK_PUBLIC libyasmine libgenesis libyasmine_model pthread boost_system boost_thread boost_chrono) - else() - target_link_libraries (libygen LINK_PUBLIC libyasmine libgenesis libyasmine_model pthread) - endif() -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - target_link_libraries (libygen LINK_PUBLIC libyasmine genesis yasmine_model) +set(link_libraries_list "") + +if("${CPP_VERSION}" STREQUAL "03") + use_boost_libraries(link_libraries_list) endif() +use_pthread(link_libraries_list) +add_library_for_linking(link_libraries_list libyasmine) +add_library_for_linking(link_libraries_list libgenesis) +add_library_for_linking(link_libraries_list libyasmine_model) +message(STATUS "libygen linking to libraries: ${link_libraries_list}" ) +target_link_libraries(libygen LINK_PUBLIC ${link_libraries_list}) + install(TARGETS libygen DESTINATION lib) file(GLOB libygen_hpp "include/*.hpp") install(FILES ${libygen_hpp} DESTINATION include/libygen/include) -set_target_properties(libygen PROPERTIES PREFIX "") \ No newline at end of file +set_target_properties(libygen PROPERTIES PREFIX "") diff --git a/libygen/include/libygen_build_number.hpp b/libygen/include/libygen_build_number.hpp index dacd405..9307981 100644 --- a/libygen/include/libygen_build_number.hpp +++ b/libygen/include/libygen_build_number.hpp @@ -24,7 +24,7 @@ namespace version { - const sxe::uint16_t BUILD_NUMBER( 751 ); + const sxe::uint16_t BUILD_NUMBER( 770 ); } diff --git a/version.txt b/version.txt index e306207..1e65d9b 100644 --- a/version.txt +++ b/version.txt @@ -1,71 +1,83 @@ Versions -• yasmine 1.4.0 released 2017-09-21 - • libyasmine 1.3.0 - • essentials 1.3.1 - • hermes 1.1.2 - • genesis 0.3.1 - • yasmine_model 0.1.2 - • libygen 0.1.1 - • ygen 0.1.3 - -• yasmine 1.3.3 released 2017-08-22 - • libyasmine 1.2.3 - • essentials 1.3.1 - • hermes 1.1.2 - • genesis 0.3.1 - • yasmine_model 0.1.2 - • libygen 0.1.1 - • ygen 0.1.3 - - -• yasmine 1.3.2 released 2017-08-18 - • libyasmine 1.2.2 - • essentials 1.3.1 - • hermes 1.1.2 - • genesis 0.3.1 - • yasmine_model 0.1.2 - • libygen 0.1.1 - • ygen 0.1.3 - - -• yasmine 1.3.1 released 2017-08-14 - • libyasmine 1.2.1 - • essentials 1.3.1 - • hermes 1.1.1 - • genesis 0.3.1 - • yasmine_model 0.1.2 - • libygen 0.1.1 - • ygen 0.1.3 - - -• yasmine 1.3.0 released 2017-06-26 - • libyasmine 1.2.0 - • essentials 1.3.0 - • hermes 1.1.0 - • genesis 0.3.0 - • yasmine_model 0.1.1 - • libygen 0.1.0 - • ygen 0.1.2 - - -• yasmine 1.2.1 released 2017-04-28 - • libyasmine 1.1.2 - • essentials 1.2.0 - • hermes 1.0.1 - • genesis 0.2.0 - • yasmine_model 0.1.0 - • libygen 0.1.0 - • ygen 0.1.1 - - -• yasmine 1.2.0 released 2017-04-25 - • libyasmine 1.1.2 - • essentials 1.2.0 - • hermes 1.0.1 - • genesis 0.2.0 - • yasmine_model 0.1.0 - • libygen 0.1.0 - • ygen 0.1.0 - - + +• yasmine 1.4.1 released 2017-10-16 + • libyasmine 1.3.1 + • essentials 1.3.1 + • hermes 1.1.2 + • genesis 0.3.1 + • yasmine_model 0.1.3 + • libygen 0.1.2 + • ygen 0.1.4 + + +• yasmine 1.4.0 released 2017-09-21 + • libyasmine 1.3.0 + • essentials 1.3.1 + • hermes 1.1.2 + • genesis 0.3.1 + • yasmine_model 0.1.2 + • libygen 0.1.1 + • ygen 0.1.3 + + +• yasmine 1.3.3 released 2017-08-22 + • libyasmine 1.2.3 + • essentials 1.3.1 + • hermes 1.1.2 + • genesis 0.3.1 + • yasmine_model 0.1.2 + • libygen 0.1.1 + • ygen 0.1.2 + + +• yasmine 1.3.2 released 2017-08-18 + • libyasmine 1.2.2 + • essentials 1.3.1 + • hermes 1.1.2 + • genesis 0.3.1 + • yasmine_model 0.1.2 + • libygen 0.1.1 + • ygen 0.1.2 + + +• yasmine 1.3.1 released 2017-08-14 + • libyasmine 1.2.1 + • essentials 1.3.1 + • hermes 1.1.1 + • genesis 0.3.1 + • yasmine_model 0.1.2 + • libygen 0.1.1 + • ygen 0.1.2 + + +• yasmine 1.3.0 released 2017-06-26 + • libyasmine 1.2.0 + • essentials 1.3.0 + • hermes 1.1.0 + • genesis 0.3.0 + • yasmine_model 0.1.2 + • libygen 0.1.0 + • ygen 0.1.1 + + +• yasmine 1.2.1 released 2017-04-28 + • libyasmine 1.1.2 + • essentials 1.2.0 + • hermes 1.0.1 + • genesis 0.2.0 + • yasmine_model 0.1.0 + • libygen 0.1.0 + • ygen 0.1.1 + + +• yasmine 1.2.0 released 2017-04-25 + • libyasmine 1.1.2 + • essentials 1.2.0 + • hermes 1.0.1 + • genesis 0.2.0 + • yasmine_model 0.1.0 + • libygen 0.1.0 + • ygen 0.1.0 + + \ No newline at end of file diff --git a/yasmine_model/CMakeLists.txt b/yasmine_model/CMakeLists.txt index 25dba4d..e221ef5 100644 --- a/yasmine_model/CMakeLists.txt +++ b/yasmine_model/CMakeLists.txt @@ -1,20 +1,12 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 2.8) project(yasmine_model) -set(CMAKE_VERBOSE_MAKEFILE, 1) - -if(SX_RAPIDJSON) - message("SX_RAPIDJSON is set by user.") -else() - message("SX_RAPIDJSON is not set by user. Setting default value.") - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(SX_RAPIDJSON "/usr/include/rapidjson") - elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - set(SX_RAPIDJSON "C:\Program Files\rapidjson") - endif() +if(POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) endif() -message(STATUS ${SX_RAPIDJSON}) + +use_rapid_JSON() file(GLOB yasmine_model_SRC "include/*.hpp" "source/*.cpp") @@ -22,68 +14,42 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if( "${CMAKE_CXX_FLAGS}" STREQUAL "-m64" ) - set(extra_flags "${extra_flags} -m64") - message(STATUS "setting platform x64") - elseif("${CMAKE_CXX_FLAGS}" STREQUAL "-m32") - set(extra_flags "${extra_flags} -m32") - message(STATUS "setting platform x86") - endif() - - - if("${CPP_VERSION}" STREQUAL "03") - set(extra_flags "${extra_flags} -std=c++03 -Wall -Wpedantic -g -Wno-unknown-pragmas -D \"SX_CPP03_BOOST\" -D \"SX_NO_VARIADIC_MACRO\"") - elseif("${CPP_VERSION}" STREQUAL "14") - set(extra_flags "${extra_flags} -std=c++14 -Wall -Wpedantic -g") - else() - set(extra_flags "${extra_flags} -std=c++11 -Wall -Wpedantic -g -D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - -endif() - - -if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" ) - # for release - if( "${CMAKE_BUILD_TYPE}" STREQUAL "Release" ) - #Creates fast code. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /PDB-") - - #Controls LINK optimizations. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /OPT:REF /OPT:ICF") - - # for debug - elseif( "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" ) - #Creates a program database (PDB) file. - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /PDB") - endif() -endif() - +include(./../CMakeHelpers/addSpecificFlags.cmake) +include(./../CMakeHelpers/addYasmineOptions.cmake) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${extra_flags}") -include_directories(${SX_RAPIDJSON}) include_directories("./../yasmine_model/include") include_directories("./../externals/essentials/include") if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - add_library(libyasmine_model SHARED ${yasmine_model_SRC}) + add_library(libyasmine_model ${LINK_TYPE} ${yasmine_model_SRC}) elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") add_library(yasmine_model STATIC ${yasmine_model_SRC}) endif() +set(link_libraries_list "") +use_pthread(link_libraries_list) + +if("${CPP_VERSION}" STREQUAL "03") + use_boost_libraries(link_libraries_list) +endif() + +message(STATUS "libyasmine_model linking to libraries: ${link_libraries_list}" ) if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if("${CPP_VERSION}" STREQUAL "03") - target_link_libraries (libyasmine_model LINK_PUBLIC pthread boost_system boost_thread boost_chrono) - else() - target_link_libraries (libyasmine_model LINK_PUBLIC pthread) - endif() + target_link_libraries(libyasmine_model LINK_PUBLIC ${link_libraries_list}) elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - target_link_libraries (yasmine_model LINK_PUBLIC) + target_link_libraries(yasmine_model LINK_PUBLIC ${link_libraries_list}) endif() -install(TARGETS libyasmine_model DESTINATION lib) + file(GLOB yasmine_model_hpp "include/*.hpp") install(FILES ${yasmine_model_hpp} DESTINATION include/yasmine_model/include) -set_target_properties(libyasmine_model PROPERTIES PREFIX "") \ No newline at end of file + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + install(TARGETS libyasmine_model DESTINATION lib) + set_target_properties(libyasmine_model PROPERTIES PREFIX "") +elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + install(TARGETS yasmine_model DESTINATION lib) + set_target_properties(yasmine_model PROPERTIES PREFIX "") +endif() diff --git a/yasmine_model/changelog.txt b/yasmine_model/changelog.txt index c353783..8dc92d6 100644 --- a/yasmine_model/changelog.txt +++ b/yasmine_model/changelog.txt @@ -2,6 +2,12 @@ All notable changes to this project are documented in this file. +##[0.1.3] - 2017-10-16 + +### Fixed +• include path of prettywriter header +• fixed integer conversion warnings + ##[0.1.2] - 2017-09-21 ### Fixed diff --git a/yasmine_model/include/build_number.hpp b/yasmine_model/include/build_number.hpp index b7dcf46..8c97408 100644 --- a/yasmine_model/include/build_number.hpp +++ b/yasmine_model/include/build_number.hpp @@ -24,7 +24,7 @@ namespace version { - const sxe::uint16_t BUILD_NUMBER( 751 ); + const sxe::uint16_t BUILD_NUMBER( 770 ); } diff --git a/yasmine_model/include/json_parser_helper.hpp b/yasmine_model/include/json_parser_helper.hpp index dee09ed..4475db4 100644 --- a/yasmine_model/include/json_parser_helper.hpp +++ b/yasmine_model/include/json_parser_helper.hpp @@ -14,7 +14,7 @@ #include -#include "document.h" +#include #include "essentials/compatibility/compatibility.hpp" diff --git a/yasmine_model/include/json_reader.hpp b/yasmine_model/include/json_reader.hpp index 8de7954..a0f02ec 100644 --- a/yasmine_model/include/json_reader.hpp +++ b/yasmine_model/include/json_reader.hpp @@ -82,9 +82,9 @@ class json_reader SX_FINAL model::entry_point_model_uptr read_entry_point( const rapidjson::Value& _pseudostate ); model::exit_point_model_uptr read_exit_point( const rapidjson::Value& _pseudostate ); model::transition_model_uptr read_transition( const rapidjson::Value& _transition ); - static sxy::model::transition_model_kind get_transition_kind( unsigned int _kind ); - sxe::int64_t get_event_id_by_name( const std::string& _name ) const; - sxe::int64_t get_event_priority_by_name( const std::string& _name ) const; + static sxy::model::transition_model_kind get_transition_kind( sxe::int64_t _kind ); + sxe::int32_t get_event_id_by_name( const std::string& _name ) const; + sxe::int8_t get_event_priority_by_name( const std::string& _name ) const; void get_event_list( model::state_machine_model_ptr& _model ); void check_document() const; diff --git a/yasmine_model/include/model_version.hpp b/yasmine_model/include/model_version.hpp index 89bdffe..627680e 100644 --- a/yasmine_model/include/model_version.hpp +++ b/yasmine_model/include/model_version.hpp @@ -9,8 +9,8 @@ ////////////////////////////////////////////////////////////////////////////////////////////////////// -#ifndef VERSION_E55DC329_9A27_4598_928C_1CD8A4AA389E -#define VERSION_E55DC329_9A27_4598_928C_1CD8A4AA389E +#ifndef MODEL_VERSION_746D9C5D_6734_4D0F_A9AF_79A147982FBB +#define MODEL_VERSION_746D9C5D_6734_4D0F_A9AF_79A147982FBB #include "essentials/compatibility/compatibility.hpp" diff --git a/yasmine_model/source/json_parser_helper.cpp b/yasmine_model/source/json_parser_helper.cpp index 4f14474..4c09daf 100644 --- a/yasmine_model/source/json_parser_helper.cpp +++ b/yasmine_model/source/json_parser_helper.cpp @@ -39,7 +39,7 @@ std::string get_object_member_string( const rapidjson::Value& _obj, const char* sxe::int64_t get_object_member_int( const rapidjson::Value& _obj, const char* const _name_of_member ) { - int found_value = 0; + sxe::int64_t found_value = 0; if( _obj.IsObject() ) { const rapidjson::Value& found_member = find_member( _obj, _name_of_member ); diff --git a/yasmine_model/source/json_reader.cpp b/yasmine_model/source/json_reader.cpp index 996949b..bb29bfc 100644 --- a/yasmine_model/source/json_reader.cpp +++ b/yasmine_model/source/json_reader.cpp @@ -450,7 +450,7 @@ model::transition_model_uptr json_reader::read_transition( const rapidjson::Valu if( one_event->IsObject() ) { const std::string event_name = get_object_member_string( sxe::ref( *one_event ), model::JSON_EVENT_NAME ); - sxe::int64_t event_id = get_event_id_by_name( event_name ); + sxe::int32_t event_id = get_event_id_by_name( event_name ); events.push_back( event_id ); } else @@ -468,7 +468,7 @@ model::transition_model_uptr json_reader::read_transition( const rapidjson::Valu } -sxy::model::transition_model_kind json_reader::get_transition_kind( unsigned int _kind ) +sxy::model::transition_model_kind json_reader::get_transition_kind( sxe::int64_t _kind ) { sxy::model::transition_model_kind kind( sxy::model::transition_model_kind::EXTERNAL ); switch( _kind ) @@ -494,9 +494,9 @@ sxy::model::transition_model_kind json_reader::get_transition_kind( unsigned int } -sxe::int64_t json_reader::get_event_id_by_name( const std::string& _name ) const +sxe::int32_t json_reader::get_event_id_by_name( const std::string& _name ) const { - sxe::int64_t event_id = sxy::model::Y_MODEL_COMPLETION_EVENT_ID; + sxe::int32_t event_id = sxy::model::Y_MODEL_COMPLETION_EVENT_ID; std::vector event_list = extract_members_from_array( get_object_member_array( document_, model::JSON_EVENT_LIST_NODE ) ); @@ -505,7 +505,8 @@ sxe::int64_t json_reader::get_event_id_by_name( const std::string& _name ) const const std::string event_name = get_object_member_string( sxe::ref( *an_event ), model::JSON_EVENT_NAME ); if( event_name == _name ) { - event_id = get_object_member_int( sxe::ref( *an_event ), model::JSON_EVENT_ID ); + // FixME: safe cast + event_id = static_cast< sxe::int32_t >( get_object_member_int( sxe::ref( *an_event ), model::JSON_EVENT_ID ) ); break; } } @@ -514,12 +515,12 @@ sxe::int64_t json_reader::get_event_id_by_name( const std::string& _name ) const } -sxe::int64_t json_reader::get_event_priority_by_name( const std::string& _name ) const +sxe::int8_t json_reader::get_event_priority_by_name( const std::string& _name ) const { #ifdef SX_CPP03_BOOST - sxe::int64_t priority ( DEFAULT_EVENT_PRIORITY); + sxe::int8_t priority ( DEFAULT_EVENT_PRIORITY); #else - sxe::int64_t priority( sxy::model::DEFAULT_EVENT_PRIORITY ); + sxe::int8_t priority( sxy::model::DEFAULT_EVENT_PRIORITY ); #endif std::vector event_list = extract_members_from_array( get_object_member_array( document_, model::JSON_EVENT_LIST_NODE ) ); @@ -531,7 +532,8 @@ sxe::int64_t json_reader::get_event_priority_by_name( const std::string& _name ) { try { - priority = get_object_member_int( sxe::ref( *an_event ), model::JSON_EVENT_PRIORITY ); + // FixME: safe cast + priority = static_cast< sxe::int8_t > ( get_object_member_int( sxe::ref( *an_event ), model::JSON_EVENT_PRIORITY ) ); } catch( ... ) { @@ -558,7 +560,9 @@ void json_reader::get_event_list( model::state_machine_model_ptr& _model ) SX_FOR( const rapidjson::Value* const an_event, event_list ) { const std::string event_name = get_object_member_string( sxe::ref( *an_event ), model::JSON_EVENT_NAME ); - sxy::model::event_id event_id = get_object_member_int( sxe::ref( *an_event ), model::JSON_EVENT_ID ); + // FixME: safe cast + sxy::model::event_id event_id = static_cast< sxy::model::event_id >( get_object_member_int( sxe::ref( *an_event ), + model::JSON_EVENT_ID ) ); #ifdef SX_CPP03_BOOST sxy::model::event_priority priority = DEFAULT_EVENT_PRIORITY; #else @@ -569,7 +573,9 @@ void json_reader::get_event_list( model::state_machine_model_ptr& _model ) const std::string json_version = get_object_member_string( document_, model::JSON_VERSION ); if( json_version != model::JSON_VERSION_1 ) { - priority = get_object_member_int( sxe::ref( *an_event ), model::JSON_EVENT_PRIORITY ); + // FixME: safe cast + priority = static_cast( get_object_member_int( sxe::ref( *an_event ), + model::JSON_EVENT_PRIORITY ) ); } } _model->add_event( event_name, event_id, priority ); diff --git a/yasmine_model/source/json_writer.cpp b/yasmine_model/source/json_writer.cpp index 26a3f31..4f21630 100644 --- a/yasmine_model/source/json_writer.cpp +++ b/yasmine_model/source/json_writer.cpp @@ -12,7 +12,7 @@ #include -#include "rapidjson/prettywriter.h" +#include "prettywriter.h" #include "essentials/exception.hpp" #include "essentials/base.hpp" diff --git a/yasmine_model/source/model_version.cpp b/yasmine_model/source/model_version.cpp index e89a6ca..7f9bfa6 100644 --- a/yasmine_model/source/model_version.cpp +++ b/yasmine_model/source/model_version.cpp @@ -12,7 +12,6 @@ #include -#include "essentials/compatibility/compatibility.hpp" #include "essentials/sxprintf.hpp" #include "build_number.hpp" @@ -31,8 +30,8 @@ namespace const sxe::uint16_t VERSION_MAJOR( 0 ); -const sxe::uint16_t VERSION_MINOR( 1 ); -const sxe::uint16_t VERSION_PATCH( 1 ); +const sxe::uint16_t VERSION_MINOR( 2 ); +const sxe::uint16_t VERSION_PATCH( 0 ); } diff --git a/yasmine_model/yasmine_model.vcxproj b/yasmine_model/yasmine_model.vcxproj index 313cb88..3bdae37 100644 --- a/yasmine_model/yasmine_model.vcxproj +++ b/yasmine_model/yasmine_model.vcxproj @@ -122,6 +122,7 @@ + diff --git a/yasmine_model/yasmine_model.vcxproj.filters b/yasmine_model/yasmine_model.vcxproj.filters index d01f8e4..96699d8 100644 --- a/yasmine_model/yasmine_model.vcxproj.filters +++ b/yasmine_model/yasmine_model.vcxproj.filters @@ -419,6 +419,9 @@ Headerdateien\state machine\element + + Headerdateien\externals\essentials\compatibility + diff --git a/ygen/CMakeLists.txt b/ygen/CMakeLists.txt index 65cf38c..3e115bb 100644 --- a/ygen/CMakeLists.txt +++ b/ygen/CMakeLists.txt @@ -1,8 +1,10 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 2.8) project(ygen) -set(CMAKE_VERBOSE_MAKEFILE, 1) +if(POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) +endif() file(GLOB ygen_SRC "source/*.cpp" "include/*.hpp") @@ -10,118 +12,25 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) - -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if( "${CMAKE_CXX_FLAGS}" STREQUAL "-m64" ) - set(extra_flags "${extra_flags} -m64") - message(STATUS "setting platform x64") - elseif( "${CMAKE_CXX_FLAGS}" STREQUAL "-m32") - set(extra_flags "${extra_flags} -m32") - message(STATUS "setting platform x86") - endif() - - if("${CPP_VERSION}" STREQUAL "03") - set(extra_flags "${extra_flags} -std=c++03 -Wall -Wpedantic -g -Wno-unknown-pragmas -D \"SX_CPP03_BOOST\" -D \"SX_NO_VARIADIC_MACRO\"") - elseif("${CPP_VERSION}" STREQUAL "14") - set(extra_flags "${extra_flags} -std=c++14 -Wall -Wpedantic -g") - else() - set(extra_flags "${extra_flags} -std=c++11 -Wall -Wpedantic -g -D \"SX_NO_STD_MAKE_UNIQUE\"") - endif() - -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - # Checks buffer security. - set(extra_flags "${extra_flags} /GS") - - #Sets output warning level. - set(extra_flags "${extra_flags} /W4") - - #Disable specific Warnings. - set(extra_flags "${extra_flags} /wd\"4127\" /wd\"4250\"") - - #Defines constants and macros. - set(extra_flags "${extra_flags} /D \"_CRT_SECURE_NO_WARNINGS\"") - - #Enables function-level linking. - set(extra_flags "${extra_flags} /Gy") - - #Specifies standard behavior under /Ze. - set(extra_flags "${extra_flags} /Zc:wchar_t /Zc:inline") - - #Disable minimal rebuild. - set(extra_flags "${extra_flags} /Gm-") - - #Enables additional security features and warnings. - set(extra_flags "${extra_flags} /sdl") - - #Specifies floating-point behavior. - set(extra_flags "${extra_flags} /fp:precise") - - #Multibyte character sets macro. - set(extra_flags "${extra_flags} /D \"_MBCS\"") - - #Enables you to provide internal compiler error (ICE) information directly to the Visual C++ team. - set(extra_flags "${extra_flags} /errorReport:prompt") - - #Treats warnings as errors. - set(extra_flags "${extra_flags} /WX") - - #Generates intrinsic functions. - set(extra_flags "${extra_flags} /Oi") - - #Specifies the model of exception handling. - set(extra_flags "${extra_flags} /EHsc") - - #Creates an object file. - set(extra_flags "${extra_flags} /Fo") - - #Marks an executable as verified to be compatible with the Windows Data Execution Prevention feature. - set(extra_flags "${extra_flags} /NXCOMPAT") - - # for release - if( "${CMAKE_BUILD_TYPE}" STREQUAL "Release" ) - #Creates fast code. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2") - - #Controls LINK optimizations. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /OPT:REF /OPT:ICF") - - # for debug - elseif( "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" ) - #Creates a program database (PDB) file. - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /PDB") - endif() - -endif() +include(./../CMakeHelpers/addSpecificFlags.cmake) +include(./../CMakeHelpers/addYasmineOptions.cmake) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${extra_flags}") +include(./../CMakeHelpers/addBoost.cmake) add_executable(ygen ${ygen_SRC}) + +set(link_libraries_list "") +use_boost_libraries(link_libraries_list) +use_pthread(link_libraries_list) +add_library_for_linking(link_libraries_list libygen) +message(STATUS "ygen linking to libraries: ${link_libraries_list}" ) +target_link_libraries(ygen LINK_PUBLIC ${link_libraries_list}) + include_directories("./include") include_directories("./../externals/essentials/include") include_directories("./../genesis/include") include_directories("./../libygen/include") -#using boost -if("${CPP_VERSION}" STREQUAL "03") - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - link_directories("${SX_BOOST_LIB_PATH}") - endif() -endif() - - -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - #SET(Boost_USE_STATIC_LIBS ON) - SET(BOOST_ROOT "${SX_BOOST_LIB_INCLUDE}") - SET(Boost_INCLUDE_DIRS "${SX_BOOST_LIB_INCLUDE}") - include_directories(${Boost_INCLUDE_DIRS}) - target_link_libraries(ygen LINK_PUBLIC ${Boost_LIBRARIES}) - target_link_libraries(ygen LINK_PUBLIC "boost_program_options") - target_link_libraries(ygen LINK_PUBLIC "boost_filesystem") - target_link_libraries (ygen LINK_PUBLIC libygen) -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - target_link_libraries (ygen LINK_PUBLIC libygen) -endif() - - install(TARGETS ygen DESTINATION bin) diff --git a/ygen/include/ygen_build_number.hpp b/ygen/include/ygen_build_number.hpp index 4cad28d..07fe407 100644 --- a/ygen/include/ygen_build_number.hpp +++ b/ygen/include/ygen_build_number.hpp @@ -20,7 +20,7 @@ namespace version { - const sxe::uint16_t BUILD_NUMBER( 751 ); + const sxe::uint16_t BUILD_NUMBER( 770 ); } diff --git a/ygen/source/ygen_version.cpp b/ygen/source/ygen_version.cpp index cc2d551..64a37b6 100644 --- a/ygen/source/ygen_version.cpp +++ b/ygen/source/ygen_version.cpp @@ -12,7 +12,6 @@ #include -#include "essentials/compatibility/compatibility.hpp" #include "essentials/sxprintf.hpp" #include "ygen_build_number.hpp" diff --git a/ygen/ygen.vcxproj b/ygen/ygen.vcxproj index 5ef576e..c296b5b 100644 --- a/ygen/ygen.vcxproj +++ b/ygen/ygen.vcxproj @@ -303,13 +303,13 @@ + - - +