Skip to content

Commit

Permalink
Merge pull request #24 from SeadexGmbH/yasmine-1.4.1
Browse files Browse the repository at this point in the history
yasmine 1.4.1
  • Loading branch information
SeadexTM authored Oct 16, 2017
2 parents 77e7b71 + decae15 commit d642afa
Show file tree
Hide file tree
Showing 76 changed files with 931 additions and 2,112 deletions.
34 changes: 34 additions & 0 deletions CMakeHelpers/addBoost.cmake
Original file line number Diff line number Diff line change
@@ -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()
112 changes: 112 additions & 0 deletions CMakeHelpers/addSpecificFlags.cmake
Original file line number Diff line number Diff line change
@@ -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()
53 changes: 53 additions & 0 deletions CMakeHelpers/addYasmineOptions.cmake
Original file line number Diff line number Diff line change
@@ -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()

22 changes: 22 additions & 0 deletions CMakeHelpers/functions.cmake
Original file line number Diff line number Diff line change
@@ -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()
15 changes: 15 additions & 0 deletions CMakeHelpers/functionsAddCompilerFlags.cmake
Original file line number Diff line number Diff line change
@@ -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()
23 changes: 23 additions & 0 deletions CMakeHelpers/functionsRapidJSON.cmake
Original file line number Diff line number Diff line change
@@ -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()
12 changes: 12 additions & 0 deletions CMakeHelpers/setVariables.cmake
Original file line number Diff line number Diff line change
@@ -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()
22 changes: 20 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
add_subdirectory(examples)
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 2.8)

add_subdirectory(hello_yasmine)
add_subdirectory(classic_farmroad)
Expand Down
Loading

0 comments on commit d642afa

Please sign in to comment.