94 lines
2.7 KiB
CMake
94 lines
2.7 KiB
CMake
cmake_minimum_required(VERSION 3.18)
|
|
project(PokemonScriptTester)
|
|
|
|
include(CPM.cmake)
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
set(BUILD_SHARED_LIBS OFF)
|
|
|
|
option(WINDOWS "Whether the build target is Windows or not." OFF)
|
|
set(SHARED OFF)
|
|
|
|
if (WINDOWS)
|
|
SET(ANGELSCRIPT_DEBUGGER OFF)
|
|
else()
|
|
SET(ANGELSCRIPT_DEBUGGER ON)
|
|
endif()
|
|
|
|
execute_process(COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/include)
|
|
CPMAddPackage(
|
|
NAME PkmnLib
|
|
GIT_REPOSITORY https://git.p-epsilon.com/Deukhoofd/PkmnLib.git
|
|
GIT_TAG master
|
|
OPTIONS
|
|
"SHARED=${SHARED}"
|
|
"WINDOWS=${WINDOWS}"
|
|
"ANGELSCRIPT_DEBUGGER=${ANGELSCRIPT_DEBUGGER}"
|
|
)
|
|
execute_process(COMMAND ln -sf ${PkmnLib_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/include/PkmnLib)
|
|
|
|
CPMAddPackage(
|
|
NAME Angelscript
|
|
GIT_REPOSITORY https://git.p-epsilon.com/Deukhoofd/Angelscript.git
|
|
GIT_TAG master
|
|
DOWNLOAD_ONLY YES
|
|
)
|
|
include_directories(${Angelscript_SOURCE_DIR}/angelscript/include)
|
|
include_directories(${Angelscript_SOURCE_DIR}/add_on)
|
|
|
|
|
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
add_compile_options(-fconcepts)
|
|
endif ()
|
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
add_link_options(-fuse-ld=lld)
|
|
endif ()
|
|
|
|
set(SRC_FILES_PATTERN src/*.cpp src/*.hpp)
|
|
if (NOT WINDOWS)
|
|
set(SRC_FILES_PATTERN ${SRC_FILES_PATTERN} extern/AngelscriptDebugger/src/*.cpp)
|
|
endif()
|
|
file(GLOB_RECURSE SRC_FILES ${SRC_FILES_PATTERN})
|
|
add_executable(PokemonScriptTester ${SRC_FILES})
|
|
|
|
target_include_directories(PokemonScriptTester PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include/)
|
|
target_include_directories(PokemonScriptTester PUBLIC ${PkmnLib_BINARY_DIR}/include/)
|
|
target_link_directories(PokemonScriptTester PUBLIC ${Angelscript_BINARY_DIR})
|
|
|
|
add_definitions(-DLEVEL_U8)
|
|
if (NOT WINDOWS)
|
|
ADD_DEFINITIONS(-DANGELSCRIPT_DEBUGGER)
|
|
endif()
|
|
|
|
SET(_LINKS -static pkmnLib Arbutils)
|
|
|
|
if (NOT WINDOWS)
|
|
SET(_LINKS ${_LINKS} AngelscriptDebugger)
|
|
endif()
|
|
|
|
if (WINDOWS)
|
|
SET(_LINKS ${_LINKS} -Wl,-Bstatic -lgcc -lstdc++ -lpthread -Wl,-Bdynamic)
|
|
endif()
|
|
|
|
target_link_libraries(PokemonScriptTester PUBLIC ${_LINKS})
|
|
target_compile_options(PokemonScriptTester PRIVATE -Wall -Wextra -Werror)
|
|
|
|
if (WINDOWS)
|
|
MESSAGE(WARNING, "Using Windows Build.")
|
|
# Add a definition for the compiler, so we can use it in C++ as well.
|
|
ADD_DEFINITIONS(-D WINDOWS=1)
|
|
# -m64: Build a 64 bit library
|
|
add_compile_options(-m64)
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-allow-multiple-definition")
|
|
if (SHARED)
|
|
set_target_properties(PokemonScriptTester PROPERTIES SUFFIX ".exe")
|
|
endif(SHARED)
|
|
endif (WINDOWS)
|
|
|
|
set(PRE_CONFIGURE_FILE "git.h.in")
|
|
set(POST_CONFIGURE_FILE "src/git.h")
|
|
include(git_watcher.cmake)
|
|
add_dependencies(PokemonScriptTester check_git)
|