ModEasy, a c++ library, is an easy to add modding system that is functional out of the box, but also designed to be extendable for whatever you may need.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
4.3KB

  1. ####################
  2. #Configure PROJECT
  3. ####################
  4. # set the PROJECT version number
  5. set (VERSION_MAJOR 0)
  6. set (VERSION_MINOR 0)
  7. set (VERSION_PATCH 0)
  8. set (VERSION_NUMBER "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
  9. # Set required cmake version and project details
  10. cmake_minimum_required (VERSION 3.0)
  11. project ("ModdingFramework" VERSION "${VERSION_NUMBER}" LANGUAGES CXX)
  12. set (LIBRARY_TYPE SHARED) #Options: SHARED, STATIC, MODULAR
  13. # Set some project path variables
  14. set( PROJECT_CODE_DIR ${PROJECT_SOURCE_DIR}/src )
  15. set( PROJECT_HEADER_DIR ${PROJECT_SOURCE_DIR}/src )
  16. set( PROJECT_DEP_DIR ${PROJECT_SOURCE_DIR}/dependencies)
  17. set( PROJECT_TEST_DIR ${PROJECT_SOURCE_DIR}/tests )
  18. # Find required libraries
  19. #> For Lua mod support
  20. #find_package(Lua 5.3 REQUIRED)
  21. #Include header directories
  22. #>For ini file parsing
  23. include_directories( "${PROJECT_DEP_DIR}/cpp-feather-ini-parser" )
  24. #>For LUA mod support
  25. #include_directories( "${PROJECT_DEP_DIR}/sol2/single/sol/" )
  26. #include_directories( "${LUA_INCLUDE_DIR}" )
  27. # Pull together all package libraries to link with the main executable
  28. set( LINK_LIBRARIES "" )
  29. #TODO add lines like this: list( APPEND LINK_LIBRARIES ${CURSES_LIBRARIES} )
  30. # Set compiler flags for different release types
  31. #set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++14 -g -Wall -Weffc++") #TODO Tweak for the project
  32. #set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++14 -Wall -Weffc++") #TODO Tweak for the project
  33. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -g -Wall -Weffc++") #TODO Tweak for the project
  34. #set paths for the source file that hold all the version info
  35. set (VERSION_SOURCE_CONFIG_FILE_PATH "${CMAKE_SOURCE_DIR}/src/version.h.in")
  36. set (VERSION_SOURCE_TARGET_FILE_PATH "${CMAKE_SOURCE_DIR}/src/version.h")
  37. #Use this in C++ to pull in the version string
  38. # * create file at VERSION_SOURCE_CONFIG_FILE_PATH (i.e. ${CMAKE_SOURCE_DIR}/src/version.h.in)
  39. # * write it like a normal header but instead of data use
  40. # @PROJECT_NAME@, @VERSION_MAJOR@, @VERSION_MINOR@, @VERSION_PATCH@, @VERSION_GIT@, and @VERSION_STRING@
  41. ###############################
  42. #Finished Configuring Project
  43. ###############################
  44. #everything else is automatic
  45. #setup version file
  46. #>handle git version string
  47. if ( EXISTS "${CMAKE_SOURCE_DIR}/.git" )
  48. execute_process( COMMAND git rev-parse HEAD
  49. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  50. OUTPUT_VARIABLE VERSION_GIT )
  51. string(REGEX REPLACE "\n$" "" VERSION_GIT "${VERSION_GIT}")
  52. endif()
  53. #> add on git repo sha to version number if avalible.
  54. if (VERSION_GIT)
  55. set(VERSION_NUMBER "${VERSION_NUMBER}.${VERSION_GIT}")
  56. endif()
  57. #> Set version string that will be used in the version config file
  58. set( VERSION_STRING "${PROJECT_NAME} Version: ${VERSION_NUMBER}" )
  59. #> Create the version source file if config file is avalible
  60. if ( EXISTS ${VERSION_SOURCE_CONFIG_FILE_PATH} )
  61. configure_file(${VERSION_SOURCE_CONFIG_FILE_PATH} ${VERSION_SOURCE_TARGET_FILE_PATH} @ONLY)
  62. else()
  63. message(WARNING "Could not find version config source file at ${VERSION_SOURCE_CONFIG_FILE_PATH}. Look at CMakeLists.txt VERSION_SOURCE_CONFIG_FILE_PATH variable for more info.")
  64. endif()
  65. #Platform detection
  66. #TODO handle cpu type i.e. 32bit
  67. if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
  68. add_definitions( -Dlinux )
  69. elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
  70. add_definitions( -Dwindows )
  71. elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
  72. add_definitions( -Dmac )
  73. #else
  74. #TODO handle extra platforms/errors
  75. endif()
  76. #Add unit tests directory
  77. #>Enable testing globally. Individual tests may be found in the tests dir as set below
  78. ENABLE_TESTING()
  79. ADD_SUBDIRECTORY( ${PROJECT_TEST_DIR} )
  80. Message("-- See ${PROJECT_BINARY_DIR}/Testing/Temporary/LastTest.log for details on tests.")
  81. # Collect source file paths into a var for later building
  82. file(GLOB_RECURSE PROJECT_SOURCES "${PROJECT_CODE_DIR}/*.cpp")
  83. file(GLOB_RECURSE PROJECT_HEADERS "${PROJECT_HEADER_DIR}/*.h")
  84. set (PROJECT_INCLUDE_DIRS "${PROJECT_HEADER_DIR}")
  85. # Build project and link it
  86. add_library(${PROJECT_NAME} ${LIBRARY_TYPE} ${PROJECT_SOURCES} )
  87. target_include_directories( ${PROJECT_NAME} PRIVATE ${PROJECT_INCLUDE_DIRS} )
  88. target_link_libraries( ${PROJECT_NAME} ${LINK_LIBRARIES} )
  89. #Build example bianries
  90. add_subdirectory(examples/1_minimal)