diff --git a/.gitignore b/.gitignore index 933e1b8c..22d2271d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,11 @@ +# CLion +.idea/ +cmake-build-*/ + +# Visual Studio 2022 +.vs/ build/ lib/ -.vs/ -.idea/ +out/ CMakeSettings.json -CMakeUserPresets.json -cmake-build-* -out/ \ No newline at end of file +/CMakeUserPresets.json diff --git a/CMakeLists.txt b/CMakeLists.txt index 166dd9d5..8b95bfbc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.20) project(ja2) +include(cmake/CopyUserPresetTemplate.cmake) +CopyUserPresetTemplate() + set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/CMakePresets.json b/CMakePresets.json deleted file mode 100644 index 89c13bbc..00000000 --- a/CMakePresets.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "version": 3, - "configurePresets": [ - { - "name": "default", - "hidden": true, - "generator": "Ninja", - "binaryDir": "${sourceDir}/out/build/${presetName}", - "cacheVariables": { - "Languages": "CHINESE;DUTCH;ENGLISH;FRENCH;GERMAN;ITALIAN;POLISH;RUSSIAN", - "Applications": "JA2;JA2MAPEDITOR;JA2UB;JA2UBMAPEDITOR", - "CMAKE_RUNTIME_OUTPUT_DIRECTORY": "." - }, - "architecture": { - "value": "x86", - "strategy": "external" - } - }, - { - "name": "Debug", - "displayName": "Debug", - "inherits": "default", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug" - } - }, - { - "name": "RelWithDebInfo", - "displayName": "RelWithDebInfo", - "inherits": "default", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "RelWithDebInfo" - } - }, - { - "name": "Release", - "displayName": "Release", - "inherits": "default", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release" - } - } - ] -} \ No newline at end of file diff --git a/cmake/CopyUserPresetTemplate.cmake b/cmake/CopyUserPresetTemplate.cmake new file mode 100644 index 00000000..484f7ec8 --- /dev/null +++ b/cmake/CopyUserPresetTemplate.cmake @@ -0,0 +1,11 @@ +function(CopyUserPresetTemplate) + if( + NOT DEFINED Languages AND + NOT DEFINED Applications AND + NOT EXISTS "${CMAKE_SOURCE_DIR}/CMakePresets.json" AND + NOT EXISTS "${CMAKE_SOURCE_DIR}/CMakeUserPresets.json" + ) + file(COPY "${CMAKE_SOURCE_DIR}/cmake/presets/CMakeUserPresets.json" DESTINATION "${CMAKE_SOURCE_DIR}") + message(FATAL_ERROR "No existing preset was found, copied a preset template to ${CMAKE_SOURCE_DIR}/CMakeUserPresets.json.") + endif() +endfunction() diff --git a/cmake/presets/CMakeUserPresets.json b/cmake/presets/CMakeUserPresets.json new file mode 100644 index 00000000..ffbc4788 --- /dev/null +++ b/cmake/presets/CMakeUserPresets.json @@ -0,0 +1,44 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "__userBase", + "hidden": true, + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/${presetName}", + "cacheVariables": { + // Valid choices: ENGLISH;GERMAN;FRENCH;ITALIAN;POLISH;DUTCH;RUSSIAN;CHINESE. If empty (""), will configure all. + "Languages": "ENGLISH", + // Valid choices: JA2;JA2MAPEDITOR;JA2UB;JA2UBMAPEDITOR. If empty (""), will configure all. + "Applications": "JA2", + // For debugging: enter your desired gamedir. e.g. C:/Games/JA2 + "CMAKE_RUNTIME_OUTPUT_DIRECTORY": "." + }, + "architecture": { + "value": "x86", + "strategy": "external" + } + }, + { + "name": "1dot13 RelWithDebInfo", + "inherits": "__userBase", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "RelWithDebInfo" + } + }, + { + "name": "1dot13 Release", + "inherits": "__userBase", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "1dot13 Debug", + "inherits": "__userBase", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + } + ] +}