Skip to content

Commit

Permalink
Added support for multiconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
MatejSakmary committed Mar 20, 2024
1 parent 79d18d3 commit 257e268
Show file tree
Hide file tree
Showing 27 changed files with 1,574 additions and 20 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ auto_vk_toolkit/lib/
# CMake output directory and Visual Studio cache/options directory if opened as CMake projec
out/
.vs/
.cache/

# CLion cache
.idea/
22 changes: 22 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "cppdbg",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"args": [],
"stopAtEntry": false,
"cwd": "${command:cmake.launchTargetDirectory}/..",
"environment": [],
"linux": {
"type": "lldb"
},
"windows": {
"type": "cppvsdbg",
"console": "externalTerminal"
}
}
]
}
93 changes: 93 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
{
"files.associations": {
"xstring": "cpp",
"any": "cpp",
"atomic": "cpp",
"charconv": "cpp",
"deque": "cpp",
"list": "cpp",
"vector": "cpp",
"xhash": "cpp",
"forward_list": "cpp",
"fstream": "cpp",
"functional": "cpp",
"ios": "cpp",
"locale": "cpp",
"memory": "cpp",
"optional": "cpp",
"regex": "cpp",
"sstream": "cpp",
"streambuf": "cpp",
"variant": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocbuf": "cpp",
"xlocmes": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xloctime": "cpp",
"xmemory": "cpp",
"algorithm": "cpp",
"cmath": "cpp",
"array": "cpp",
"bit": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"chrono": "cpp",
"clocale": "cpp",
"codecvt": "cpp",
"compare": "cpp",
"complex": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"exception": "cpp",
"map": "cpp",
"set": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"filesystem": "cpp",
"format": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"iterator": "cpp",
"limits": "cpp",
"mutex": "cpp",
"new": "cpp",
"numeric": "cpp",
"ostream": "cpp",
"queue": "cpp",
"ranges": "cpp",
"ratio": "cpp",
"shared_mutex": "cpp",
"span": "cpp",
"stack": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"system_error": "cpp",
"thread": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"utility": "cpp",
"valarray": "cpp",
"xfacet": "cpp",
"xlocinfo": "cpp",
"xstddef": "cpp",
"xtr1common": "cpp",
"xtree": "cpp",
"xutility": "cpp"
}
}
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ project(Auto_Vk_Toolkit)

if (MSVC)
# <ranges> support requires /std:c++latest on MSVC
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD 20)
else (MSVC)
set(CMAKE_CXX_STANDARD 20)
endif (MSVC)
Expand Down Expand Up @@ -199,16 +199,17 @@ else()
stb)
endif(UNIX)



if (UNIX)
# pthreads
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(${PROJECT_NAME} ${avk_toolkit_IncludeScope}
Threads::Threads)
elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
else()
# explicitly link dbghelp to debug builds on Windows
target_link_libraries(${PROJECT_NAME} ${avk_toolkit_IncludeScope}
dbghelp)
target_link_libraries(${PROJECT_NAME} ${avk_toolkit_IncludeScope} $<$<CONFIG:Debug>:dbghelp>)
endif (UNIX)

# add avk_toolkit.hpp as precomiled header
Expand Down
90 changes: 90 additions & 0 deletions CmakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 21,
"patch": 0
},
"configurePresets": [
{
"name": "defaults",
"hidden": true,
"binaryDir": "${sourceDir}/out/${presetName}",
"generator": "Ninja Multi-Config",
"cacheVariables": {
"avk_toolkit_BuildExamples" : true,
"gvk_CreateDependencySymlinks": false,
"CMAKE_EXPORT_COMPILE_COMMANDS" : true
}
},
{
"name": "defaults-windows",
"hidden": true,
"inherits": [
"defaults"
],
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"cacheVariables": {
}
},
{
"name": "clang-x86_64-windows-msvc",
"displayName": "Clang x86_64 Windows (MSVC ABI)",
"inherits": [
"defaults-windows"
],
"toolchainFile": "${sourceDir}/cmake/toolchains/clang-x86_64-windows-msvc.cmake"
},
{
"name": "cl-x86_64-windows-msvc",
"displayName": "CL.exe x86_64 Windows (MSVC ABI)",
"inherits": [
"defaults-windows"

],
"toolchainFile": "${sourceDir}/cmake/toolchains/cl-x86_64-windows-msvc.cmake"
}
],
"buildPresets": [
{
"name": "clang-x86_64-windows-msvc-debug",
"displayName": "Clang x86_64 Windows (MSVC ABI) Debug",
"configurePreset": "clang-x86_64-windows-msvc",
"configuration": "Debug"
},
{
"name": "clang-x86_64-windows-msvc-relwithdebinfo",
"displayName": "Clang x86_64 Windows (MSVC ABI) RelWithDebInfo",
"configurePreset": "clang-x86_64-windows-msvc",
"configuration": "RelWithDebInfo"
},
{
"name": "clang-x86_64-windows-msvc-release",
"displayName": "Clang x86_64 Windows (MSVC ABI) Release",
"configurePreset": "clang-x86_64-windows-msvc",
"configuration": "Release"
},
{
"name": "cl-x86_64-windows-msvc-debug",
"displayName": "CL.exe x86_64 Windows (MSVC ABI) Debug",
"configurePreset": "cl-x86_64-windows-msvc",
"configuration": "Debug"
},
{
"name": "cl-x86_64-windows-msvc-relwithdebinfo",
"displayName": "CL.exe x86_64 Windows (MSVC ABI) RelWithDebInfo",
"configurePreset": "cl-x86_64-windows-msvc",
"configuration": "RelWithDebInfo"
},
{
"name": "cl-x86_64-windows-msvc-release",
"displayName": "CL.exe x86_64 Windows (MSVC ABI) Release",
"configurePreset": "cl-x86_64-windows-msvc",
"configuration": "Release"
}
]
}
41 changes: 41 additions & 0 deletions cmake/toolchains/cl-x86_64-windows-msvc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Don't set the MSVC compiler.. This works when opening the folder in Visual Studio
include(${CMAKE_CURRENT_LIST_DIR}/vcvars.cmake)

find_program(CMAKE_C_COMPILER cl REQUIRED HINTS ${MSVC_ENV_Path})
find_program(CMAKE_CXX_COMPILER cl REQUIRED HINTS ${MSVC_ENV_Path})
find_program(CMAKE_MT mt REQUIRED HINTS ${MSVC_ENV_Path})
find_program(CMAKE_RC_COMPILER rc REQUIRED HINTS ${MSVC_ENV_Path})

set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT MSVC)
set(CMAKE_C_COMPILER_FRONTEND_VARIANT MSVC)

list(APPEND CMAKE_C_STANDARD_INCLUDE_DIRECTORIES ${MSVC_ENV_INCLUDE})
list(REMOVE_DUPLICATES CMAKE_C_STANDARD_INCLUDE_DIRECTORIES)
set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_C_STANDARD_INCLUDE_DIRECTORIES} CACHE STRING "")

list(APPEND CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${MSVC_ENV_INCLUDE})
list(REMOVE_DUPLICATES CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES)
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES} CACHE STRING "")

list(APPEND CMAKE_RC_STANDARD_INCLUDE_DIRECTORIES ${MSVC_ENV_INCLUDE})
list(REMOVE_DUPLICATES CMAKE_RC_STANDARD_INCLUDE_DIRECTORIES)
set(CMAKE_RC_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_RC_STANDARD_INCLUDE_DIRECTORIES} CACHE STRING "")

foreach(libpath ${MSVC_ENV_LIBPATH} ${MSVC_ENV_LIB})
set(CMAKE_SHARED_LINKER_FLAGS_INIT "${CMAKE_SHARED_LINKER_FLAGS_INIT} \"/LIBPATH:${libpath}\"")
set(CMAKE_MODULE_LINKER_FLAGS_INIT "${CMAKE_MODULE_LINKER_FLAGS_INIT} \"/LIBPATH:${libpath}\"")
set(CMAKE_EXE_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS_INIT} \"/LIBPATH:${libpath}\"")
endforeach()

list(APPEND LINK_DIRECTORIES $ENV{LIB} $ENV{LIBPATH})
list(REMOVE_DUPLICATES LINK_DIRECTORIES)
set(LINK_DIRECTORIES ${LINK_DIRECTORIES} CACHE STRING "")
link_directories(BEFORE ${LINK_DIRECTORIES})

list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES
MSVC_ENV_INCLUDE
MSVC_ENV_LIBPATH
MSVC_ENV_VAR_NAMES
MSVC_ENV_Path
MSVC_ENV_LIB
)
6 changes: 6 additions & 0 deletions cmake/toolchains/clang-x86_64-linux-gnu.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x86_64)

set(CMAKE_C_COMPILER_ID Clang)
set(CMAKE_CXX_COMPILER_ID Clang)
6 changes: 6 additions & 0 deletions cmake/toolchains/clang-x86_64-windows-msvc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86_64)

set(CMAKE_C_COMPILER_ID Clang)
set(CMAKE_CXX_COMPILER_ID Clang)
6 changes: 6 additions & 0 deletions cmake/toolchains/gcc-x86_64-linux-gnu.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x86_64)

set(CMAKE_C_COMPILER_ID GNU)
set(CMAKE_CXX_COMPILER_ID GNU)
Loading

0 comments on commit 257e268

Please sign in to comment.