-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #126 from aminya/ [skip ci]
- Loading branch information
Showing
16 changed files
with
264 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
test/build | ||
.cache | ||
.cache/ | ||
test/build/ | ||
install/ | ||
test_install/build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "lldb", | ||
"request": "launch", | ||
"name": "Launch lldb", | ||
"program": "${workspaceRoot}/test/build/Debug/main", | ||
"args": [], | ||
"cwd": "${workspaceRoot}" | ||
}, | ||
{ | ||
"name": "Attach lldb", | ||
"type": "lldb", | ||
"request": "attach", | ||
"pid": "${command:pickMyProcess}" | ||
}, | ||
{ | ||
"name": "Launch gdb", | ||
"type": "cppdbg", | ||
"request": "launch", | ||
"program": "${workspaceRoot}/test/build/Debug/main", | ||
"args": [], | ||
"stopAtEntry": false, | ||
"cwd": "${workspaceRoot}", | ||
"environment": [], | ||
"externalConsole": false, | ||
"MIMode": "gdb", | ||
"miDebuggerPath": "gdb", | ||
"setupCommands": [ | ||
{ | ||
"description": "Enable pretty-printing for gdb", | ||
"text": "-enable-pretty-printing", | ||
"ignoreFailures": true | ||
}, | ||
{ | ||
"description": "Set Disassembly Flavor to Intel", | ||
"text": "-gdb-set disassembly-flavor intel", | ||
"ignoreFailures": true | ||
} | ||
] | ||
}, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# includes a separate CMakeLists.txt file to detect the CXX/C compilers before project is called | ||
# Using a separate file ensures that the current scope is not contaminated by the variable | ||
execute_process( | ||
COMMAND cmake -S "${ProjectOptions_SRC_DIR}/detect_compiler" -B "${CMAKE_CURRENT_BINARY_DIR}/detect_compiler" -G | ||
"${CMAKE_GENERATOR}" "--log-level=ERROR" "-Wno-dev" OUTPUT_QUIET) | ||
|
||
# parse the detected compilers from the cache | ||
set(cache_variables | ||
CMAKE_CXX_COMPILER | ||
CMAKE_CXX_COMPILER_ID | ||
CMAKE_C_COMPILER | ||
CMAKE_C_COMPILER_ID | ||
CMAKE_SYSTEM_PROCESSOR | ||
CMAKE_HOST_SYSTEM_PROCESSOR) | ||
foreach(cache_var ${cache_variables}) | ||
file(STRINGS "${CMAKE_CURRENT_BINARY_DIR}/detect_compiler/CMakeCache.txt" "DETECTED_${cache_var}" | ||
REGEX "^${cache_var}:STRING=(.*)$") | ||
string( | ||
REGEX | ||
REPLACE "^${cache_var}:STRING=(.*)$" | ||
"\\1" | ||
"DETECTED_${cache_var}" | ||
"${DETECTED_${cache_var}}") | ||
endforeach() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
include_guard() | ||
|
||
# detect mingw | ||
function(is_mingw value) | ||
set(_value OFF) | ||
if("${MINGW}" STREQUAL "True" OR (WIN32 AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" | ||
OR "${DETECTED_CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU"))) | ||
set(_value ON) | ||
endif() | ||
set(${value} | ||
"${_value}" | ||
PARENT_SCOPE) | ||
endfunction() | ||
|
||
# configure mingw toolchain for vcpkg | ||
# if mingw, use the correct triplet (otherwise it will fail to link libraries) | ||
macro(configure_mingw_vcpkg) | ||
if(WIN32 AND NOT MSVC) | ||
|
||
# detect mingw if not already done | ||
if(NOT | ||
"${MINGW}" | ||
STREQUAL | ||
"True") | ||
include("${ProjectOptions_SRC_DIR}/DetectCompiler.cmake") | ||
endif() | ||
|
||
is_mingw(_is_mingw) | ||
if(${_is_mingw}) | ||
include("${ProjectOptions_SRC_DIR}/Utilities.cmake") | ||
detect_architecture(_arch) | ||
string(TOLOWER "${_arch}" _arch) | ||
|
||
# https://github.com/microsoft/vcpkg/blob/4b766c1cd17205e1b768c4fadfd5f867c1d0510e/scripts/buildsystems/vcpkg.cmake#L340 | ||
set(MINGW TRUE) | ||
|
||
# https://github.com/microsoft/vcpkg/blob/7aa1a14c5f5707373b73e909ed6aa12b7bae8ee7/scripts/cmake/vcpkg_common_definitions.cmake#L54 | ||
set(VCPKG_CMAKE_SYSTEM_NAME | ||
"MinGW" | ||
CACHE STRING "") | ||
set(VCPKG_TARGET_IS_MINGW | ||
TRUE | ||
CACHE STRING "") | ||
|
||
# choose between static or dynamic | ||
set(MINGW_LINKAGE) | ||
if(BUILD_SHARED_LIBS) | ||
set(MINGW_LINKAGE "dynamic") | ||
message( | ||
STATUS | ||
"Enabled dynamic toolchain for mingw. Make sure that the mingw64/bin directory is on the PATH when running the final executables." | ||
) | ||
else() | ||
set(MINGW_LINKAGE "static") | ||
endif() | ||
|
||
set(VCPKG_LIBRARY_LINKAGE | ||
${MINGW_LINKAGE} | ||
CACHE STRING "") | ||
set(VCPKG_CRT_LINKAGE | ||
${MINGW_LINKAGE} | ||
CACHE STRING "") | ||
|
||
# Based on the docs https://github.com/microsoft/vcpkg/blob/master/docs/users/mingw.md (but it doesn't work!) | ||
set(VCPKG_DEFAULT_TRIPLET | ||
"${_arch}-mingw-${MINGW_LINKAGE}" | ||
CACHE STRING "Default triplet for vcpkg") | ||
set(VCPKG_DEFAULT_HOST_TRIPLET | ||
"${_arch}-mingw-${MINGW_LINKAGE}" | ||
CACHE STRING "Default target triplet for vcpkg") | ||
set($ENV{VCPKG_DEFAULT_TRIPLET} "${_arch}-mingw-${MINGW_LINKAGE}") | ||
set($ENV{VCPKG_DEFAULT_HOST_TRIPLET} "${_arch}-mingw-${MINGW_LINKAGE}") | ||
endif() | ||
endif() | ||
endmacro() | ||
|
||
# corrects the mingw toolchain type after including the vcpkg toolchain | ||
# Requires to be called in the same scope as configure_mingw_vcpkg() | ||
macro(configure_mingw_vcpkg_after) | ||
if(WIN32 AND MINGW) | ||
set(Z_VCPKG_TARGET_TRIPLET_PLAT mingw-${MINGW_LINKAGE}) | ||
|
||
include("${ProjectOptions_SRC_DIR}/Utilities.cmake") | ||
detect_architecture(_arch) | ||
string(TOLOWER "${_arch}" _arch) | ||
set(Z_VCPKG_TARGET_TRIPLET_ARCH ${_arch}) | ||
|
||
set(VCPKG_TARGET_TRIPLET | ||
"${Z_VCPKG_TARGET_TRIPLET_ARCH}-${Z_VCPKG_TARGET_TRIPLET_PLAT}" | ||
CACHE STRING "Vcpkg target triplet (ex. x86-windows)" FORCE) | ||
endif() | ||
endmacro() | ||
|
||
# fix unicode and main function entry on mingw | ||
macro(mingw_unicode target) | ||
is_mingw(_is_mingw) | ||
if(${_is_mingw}) | ||
include(CheckCXXCompilerFlag) | ||
check_cxx_compiler_flag("-municode" _cxx_supports_municode) | ||
if(${_cxx_supports_municode}) | ||
target_compile_definitions(${target} INTERFACE "UNICODE" "_UNICODE") | ||
target_compile_options(${target} INTERFACE "-municode") | ||
endif() | ||
endif() | ||
endmacro() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
cmake_minimum_required(VERSION 3.23) | ||
enable_language(CXX) | ||
enable_language(C) | ||
|
||
set(CMAKE_CXX_COMPILER_ID | ||
"${CMAKE_CXX_COMPILER_ID}" | ||
CACHE STRING "The CXX compiler id.") | ||
set(CMAKE_C_COMPILER_ID | ||
"${CMAKE_C_COMPILER_ID}" | ||
CACHE STRING "The C compiler id.") | ||
set(CMAKE_SYSTEM_PROCESSOR | ||
"${CMAKE_SYSTEM_PROCESSOR}" | ||
CACHE STRING "The target system processor.") | ||
set(CMAKE_HOST_SYSTEM_PROCESSOR | ||
"${CMAKE_HOST_SYSTEM_PROCESSOR}" | ||
CACHE STRING "The host system processor.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.