#################### #Configure PROJECT #################### # set the PROJECT version number set (VERSION_MAJOR 0) set (VERSION_MINOR 0) set (VERSION_PATCH 0) set (VERSION_NUMBER "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") # Set required cmake version and project details cmake_minimum_required (VERSION 3.0) project ("ModdingFramework" VERSION "${VERSION_NUMBER}" LANGUAGES CXX) set (LIBRARY_TYPE SHARED) #Options: SHARED, STATIC, MODULAR # Set some project path variables set( PROJECT_CODE_DIR ${PROJECT_SOURCE_DIR}/src ) set( PROJECT_HEADER_DIR ${PROJECT_SOURCE_DIR}/src ) set( PROJECT_DEP_DIR ${PROJECT_SOURCE_DIR}/dependencies) set( PROJECT_TEST_DIR ${PROJECT_SOURCE_DIR}/tests ) # Find required libraries #> For Lua mod support #find_package(Lua 5.3 REQUIRED) #Include header directories #>For ini file parsing include_directories( "${PROJECT_DEP_DIR}/cpp-feather-ini-parser" ) #>For LUA mod support #include_directories( "${PROJECT_DEP_DIR}/sol2/single/sol/" ) #include_directories( "${LUA_INCLUDE_DIR}" ) # Pull together all package libraries to link with the main executable set( LINK_LIBRARIES "" ) #TODO add lines like this: list( APPEND LINK_LIBRARIES ${CURSES_LIBRARIES} ) # Set compiler flags for different release types #set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++14 -g -Wall -Weffc++") #TODO Tweak for the project #set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++14 -Wall -Weffc++") #TODO Tweak for the project set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -g -Wall -Weffc++") #TODO Tweak for the project #set paths for the source file that hold all the version info set (VERSION_SOURCE_CONFIG_FILE_PATH "${CMAKE_SOURCE_DIR}/src/version.h.in") set (VERSION_SOURCE_TARGET_FILE_PATH "${CMAKE_SOURCE_DIR}/src/version.h") #Use this in C++ to pull in the version string # * create file at VERSION_SOURCE_CONFIG_FILE_PATH (i.e. ${CMAKE_SOURCE_DIR}/src/version.h.in) # * write it like a normal header but instead of data use # @PROJECT_NAME@, @VERSION_MAJOR@, @VERSION_MINOR@, @VERSION_PATCH@, @VERSION_GIT@, and @VERSION_STRING@ ############################### #Finished Configuring Project ############################### #everything else is automatic #setup version file #>handle git version string if ( EXISTS "${CMAKE_SOURCE_DIR}/.git" ) execute_process( COMMAND git rev-parse HEAD WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE VERSION_GIT ) string(REGEX REPLACE "\n$" "" VERSION_GIT "${VERSION_GIT}") endif() #> add on git repo sha to version number if avalible. if (VERSION_GIT) set(VERSION_NUMBER "${VERSION_NUMBER}.${VERSION_GIT}") endif() #> Set version string that will be used in the version config file set( VERSION_STRING "${PROJECT_NAME} Version: ${VERSION_NUMBER}" ) #> Create the version source file if config file is avalible if ( EXISTS ${VERSION_SOURCE_CONFIG_FILE_PATH} ) configure_file(${VERSION_SOURCE_CONFIG_FILE_PATH} ${VERSION_SOURCE_TARGET_FILE_PATH} @ONLY) else() 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.") endif() #Platform detection #TODO handle cpu type i.e. 32bit if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") add_definitions( -Dlinux ) elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") add_definitions( -Dwindows ) elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") add_definitions( -Dmac ) #else #TODO handle extra platforms/errors endif() #Add unit tests directory #>Enable testing globally. Individual tests may be found in the tests dir as set below ENABLE_TESTING() ADD_SUBDIRECTORY( ${PROJECT_TEST_DIR} ) Message("-- See ${PROJECT_BINARY_DIR}/Testing/Temporary/LastTest.log for details on tests.") # Collect source file paths into a var for later building file(GLOB_RECURSE PROJECT_SOURCES "${PROJECT_CODE_DIR}/*.cpp") file(GLOB_RECURSE PROJECT_HEADERS "${PROJECT_HEADER_DIR}/*.h") set (PROJECT_INCLUDE_DIRS "${PROJECT_HEADER_DIR}") # Build project and link it add_library(${PROJECT_NAME} ${LIBRARY_TYPE} ${PROJECT_SOURCES} ) target_include_directories( ${PROJECT_NAME} PRIVATE ${PROJECT_INCLUDE_DIRS} ) target_link_libraries( ${PROJECT_NAME} ${LINK_LIBRARIES} ) #Build example bianries add_subdirectory(examples/1_minimal)