Skip to content

build: Add ClangCL profiles #791

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
60e1e5b
build: Add ClangCL profiles
alichraghi Nov 21, 2024
114c549
build: one liner ifs and some fixes
alichraghi Nov 21, 2024
ff5513b
update dxc submodule
alichraghi Nov 21, 2024
44acfcf
build: simplify if
alichraghi Nov 22, 2024
dbff78d
Merge branch 'ali_clang' of github.com:Devsh-Graphics-Programming/Nabla
AnastaZIuk Apr 4, 2025
616f7d7
fixing CLang build, save work
AnastaZIuk Apr 8, 2025
aad8bb1
make Nabla Clang build work
AnastaZIuk Apr 8, 2025
7b8cb61
bad typo
AnastaZIuk Apr 8, 2025
062b5ba
update profiles & flags check handle, take care of Clang profile; ent…
AnastaZIuk Apr 11, 2025
39bb3e1
update dxc submodule with fixed clang 19.1.1 build, upgrade & correct…
AnastaZIuk Apr 11, 2025
cbb4db1
update GLI (use custom location for GLM + fix with templates) and GLM…
AnastaZIuk Apr 11, 2025
c1cc48b
explicitly set limits for Clang toolset, correct some of backend opti…
AnastaZIuk Apr 13, 2025
16088b9
Reduce device_capabilities_traits_jit.h instructions & use std::ostri…
AnastaZIuk Apr 14, 2025
8f454a9
update bzip2 submodule to latest *official* revision, adjust build sy…
AnastaZIuk Apr 14, 2025
b4e722a
remove `-Xclang=-fincremental-extensions` which causes funny compile …
AnastaZIuk Apr 14, 2025
eda05ee
adjust MSVC profile + correct incremental link options, update NBL_RE…
AnastaZIuk Apr 15, 2025
25e0120
get rid of MSVC Release linker fallback with /LTCG due to /GL - manua…
AnastaZIuk Apr 16, 2025
b5d6795
Create vendor/template/frontend/MSVC.cmake, update profiles, respect …
AnastaZIuk Apr 17, 2025
d1bb5c6
Merge branch 'master' of github.com:Devsh-Graphics-Programming/Nabla …
AnastaZIuk Apr 18, 2025
a1b9b99
ah DXC needs to point to devshFixes_clang_19_1_1
AnastaZIuk Apr 18, 2025
77ed416
keep designated initializers for ISwapchain's SSharedCreationParams, …
AnastaZIuk Apr 18, 2025
a2a7e72
for my sanity - add -DNDEBUG to Clang profile (Unix)
AnastaZIuk Apr 18, 2025
cde9e79
correct CMAKE_MSVC_DEBUG_INFORMATION_FORMAT logic hence make it work …
AnastaZIuk Apr 18, 2025
8246891
pull master & resolve conflicts
AnastaZIuk Apr 22, 2025
6e4392e
add more NEW policies, leave TODO comment for `cmake_policy`
AnastaZIuk Apr 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -493,11 +493,7 @@ if(ENABLE_HLSL)
endif()

foreach(trgt IN LISTS NBL_3RDPARTY_TARGETS)
if(NBL_DYNAMIC_MSVC_RUNTIME)
set_property(TARGET ${trgt} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
else()
set_property(TARGET ${trgt} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
set_property(TARGET ${trgt} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${NBL_COMPILER_DYNAMIC_RUNTIME}>:DLL>")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK in Clang and GCC there are options about static linking of libstd-c++

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes there are and this property has effect only if MSVC ABI is the target


if(MSVC AND NBL_SANITIZE_ADDRESS)
set_property(TARGET ${trgt} PROPERTY COMPILE_OPTIONS /fsanitize=address)
Expand Down
6 changes: 1 addition & 5 deletions 3rdparty/dxc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ if(WIN32)
endif()
endif()

if(NBL_DYNAMIC_MSVC_RUNTIME)
list(APPEND NBL_DXC_CMAKE_OPTIONS "-DCMAKE_MSVC_RUNTIME_LIBRARY:STATIC=MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
else()
list(APPEND NBL_DXC_CMAKE_OPTIONS "-DCMAKE_MSVC_RUNTIME_LIBRARY:STATIC=MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
list(APPEND NBL_DXC_CMAKE_OPTIONS "-DCMAKE_MSVC_RUNTIME_LIBRARY:STATIC=MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<BOOL:${NBL_COMPILER_DYNAMIC_RUNTIME}>:DLL>")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as with the general nabla comment

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


# perform DXC compile standard requirement test
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/dxc/dxc
14 changes: 4 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ if(MSVC)
endif()

option(NBL_STATIC_BUILD "" OFF) # ON for static builds, OFF for shared
option(NBL_DYNAMIC_MSVC_RUNTIME "" ON)
option(NBL_COMPILER_DYNAMIC_RUNTIME "" ON)
option(NBL_SANITIZE_ADDRESS OFF)

if(MSVC)
if(CMAKE_CXX_COMPILER_ID STREQUAL MSVC)
if(NBL_SANITIZE_ADDRESS)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>")
else()
Expand All @@ -34,14 +34,8 @@ endif()
if(NBL_STATIC_BUILD)
message(STATUS "Static Nabla build enabled!")
else()
if(MSVC)
if(NBL_DYNAMIC_MSVC_RUNTIME)
message(STATUS "Shared Nabla build enabled!")
else()
message(FATAL_ERROR "Turn NBL_DYNAMIC_MSVC_RUNTIME on! For dynamic Nabla builds dynamic MSVC runtime is mandatory!")
endif()
else()
message(FATAL_ERROR "Nabla can't be built with shared libraries! Please make sure you are targetting Windows OS and MSVC compiler!")
if(NOT NBL_COMPILER_DYNAMIC_RUNTIME)
message(FATAL_ERROR "Turn NBL_COMPILER_DYNAMIC_RUNTIME on! For dynamic Nabla builds dynamic runtime is mandatory!")
endif()
Comment on lines +37 to 39

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aah ok so we want to ban compiling with static-libstdc++

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes we agreed it must match

endif()

Expand Down
24 changes: 20 additions & 4 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"hidden": true,
"inherits": "ci-configure-static-base",
"cacheVariables": {
"NBL_DYNAMIC_MSVC_RUNTIME": "OFF"
"NBL_COMPILER_DYNAMIC_RUNTIME": "OFF"
},
"condition": {
"type": "allOf",
Expand All @@ -69,7 +69,7 @@
"hidden": true,
"inherits": "ci-configure-dynamic-base",
"cacheVariables": {
"NBL_DYNAMIC_MSVC_RUNTIME": "ON"
"NBL_COMPILER_DYNAMIC_RUNTIME": "ON"
},
"condition": {
"type": "allOf",
Expand Down Expand Up @@ -156,7 +156,7 @@
"hidden": true,
"inherits": "user-configure-static-base",
"cacheVariables": {
"NBL_DYNAMIC_MSVC_RUNTIME": "OFF"
"NBL_COMPILER_DYNAMIC_RUNTIME": "OFF"
},
"condition": {
"type": "equals",
Expand All @@ -169,7 +169,7 @@
"hidden": true,
"inherits": "user-configure-dynamic-base",
"cacheVariables": {
"NBL_DYNAMIC_MSVC_RUNTIME": "ON"
"NBL_COMPILER_DYNAMIC_RUNTIME": "ON"
},
"condition": {
"type": "equals",
Expand All @@ -193,6 +193,22 @@
"generator": "Visual Studio 17 2022",
"toolset": "v143"
},
{
"name": "user-configure-static-clangcl",
"inherits": "user-configure-static-windows-base",
"displayName": "[USER]: Static library target, Visual Studio 17 2022 generator, ClangCL toolset",
"description": "Configure as static library with Visual Studio 17 2022 generator and ClangCL toolset",
"generator": "Visual Studio 17 2022",
"toolset": "ClangCL"
},
{
"name": "user-configure-dynamic-clangcl",
"inherits": "user-configure-dynamic-windows-base",
"displayName": "[USER]: Dynamic library target, Visual Studio 17 2022 generator, ClangCL toolset",
"description": "Configure as dynamic library with Visual Studio 17 2022 generator and ClangCL toolset",
"generator": "Visual Studio 17 2022",
"toolset": "ClangCL"
},
{
"name": "user-configure-static-ninja-multi",
"inherits": "user-configure-static-windows-base",
Expand Down
64 changes: 52 additions & 12 deletions cmake/adjust/flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,57 @@ option(NBL_REQUEST_SSE_4_2 "Request compilation with SSE 4.2 instruction set ena
option(NBL_REQUEST_SSE_AXV2 "Request compilation with SSE Intel Advanced Vector Extensions 2 for Nabla projects" ON)

# profiles
if(MSVC)
include("${CMAKE_CURRENT_LIST_DIR}/template/windows/msvc.cmake")
elseif(ANDROID)
include("${CMAKE_CURRENT_LIST_DIR}/template/unix/android.cmake")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
include("${CMAKE_CURRENT_LIST_DIR}/template/unix/gnu.cmake")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
include("${CMAKE_CURRENT_LIST_DIR}/template/unix/clang.cmake")
else()
message(WARNING "UNTESTED COMPILER DETECTED, EXPECT WRONG OPTIMIZATION FLAGS! SUBMIT ISSUE ON GITHUB https://github.com/Devsh-Graphics-Programming/Nabla/issues")
endif()
foreach(NBL_COMPILER_LANGUAGE IN ITEMS C CXX)
# all list of all known by CMake vendors:
# https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html
set(NBL_COMPILER_VENDOR "${CMAKE_${NBL_COMPILER_LANGUAGE}_COMPILER_ID}")
set(NBL_PROFILE_NAME "${NBL_COMPILER_LANGUAGE}_${NBL_COMPILER_VENDOR}") # eg. "cxx_MSVC.cmake"
set(NBL_PROFILE_PATH "${CMAKE_CURRENT_LIST_DIR}/template/vendor/${NBL_PROFILE_NAME}.cmake")

include("${NBL_PROFILE_PATH}" RESULT_VARIABLE _NBL_FOUND_)

if(NOT _NBL_FOUND_)
message(WARNING "UNSUPPORTED \"${NBL_COMPILER_LANGUAGE}\" COMPILER LANGUAGE FOR \"${NBL_COMPILER_VENDOR}\" DETECTED, CMAKE CONFIGURATION OR BUILD MAY FAIL AND COMPILE OPTIONS FLAGS WILL NOT BE SET! SUBMIT ISSUE ON GITHUB https://github.com/Devsh-Graphics-Programming/Nabla/issues")
continue()
endif()

# a profile MUST define
# - "NBL_${NBL_COMPILER_LANGUAGE}_${CONFIGURATION}_COMPILE_OPTIONS" (configuration dependent)
# - "NBL_${NBL_COMPILER_LANGUAGE}_COMPILE_OPTIONS" (global)

# a profile MUST NOT define
# - NBL_COMPILE_OPTIONS

set(NBL_COMPILE_OPTIONS_VAR_NAME NBL_${NBL_COMPILER_LANGUAGE}_COMPILE_OPTIONS)
set(NBL_COMPILE_OPTIONS_VAR_VALUE ${${NBL_COMPILE_OPTIONS_VAR_NAME}})

if(NOT DEFINED ${NBL_COMPILE_OPTIONS_VAR_NAME})
message(FATAL_ERROR "\"${NBL_PROFILE_PATH}\" did not define \"${NBL_COMPILE_OPTIONS_VAR_NAME}\"!")
endif()

# update map with configuration dependent compile options
foreach(CONFIGURATION IN ITEMS RELEASE RELWITHDEBINFO DEBUG)
set(NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_NAME NBL_${NBL_COMPILER_LANGUAGE}_${CONFIGURATION}_COMPILE_OPTIONS)
set(NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_VALUE ${${NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_NAME}})

if(NOT DEFINED ${NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_NAME})
message(FATAL_ERROR "\"${NBL_PROFILE_PATH}\" did not define \"${NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_NAME}\"!")
endif()

list(APPEND NBL_${CONFIGURATION}_COMPILE_OPTIONS
# note that "${NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_VALUE}" MUST NOT contain ANY
# $<$<CONFIG:<>> generator expression in order to support our configuration mapping features
$<$<COMPILE_LANGUAGE:${NBL_COMPILER_LANGUAGE}>:${NBL_CONFIGURATION_COMPILE_OPTIONS_VAR_VALUE}>
)

set(NBL_${CONFIGURATION}_COMPILE_OPTIONS ${NBL_${CONFIGURATION}_COMPILE_OPTIONS})
endforeach()

# update map with global compile options
list(APPEND NBL_COMPILE_OPTIONS $<$<COMPILE_LANGUAGE:${NBL_COMPILER_LANGUAGE}>:${NBL_${NBL_COMPILER_LANGUAGE}_COMPILE_OPTIONS}>)

set(NBL_COMPILE_OPTIONS ${NBL_COMPILE_OPTIONS})
endforeach()

function(NBL_EXT_P_APPEND_COMPILE_OPTIONS NBL_LIST_NAME MAP_RELEASE MAP_RELWITHDEBINFO MAP_DEBUG)
macro(NBL_MAP_CONFIGURATION NBL_CONFIG_FROM NBL_CONFIG_TO)
Expand Down Expand Up @@ -173,7 +213,7 @@ function(nbl_adjust_flags)

set(MAPPED_CONFIG $<TARGET_GENEX_EVAL:${NBL_TARGET_ITEM},$<TARGET_PROPERTY:${NBL_TARGET_ITEM},NBL_CONFIGURATION_MAP>>)

if(MSVC)
if(MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL MSVC)
if(NBL_SANITIZE_ADDRESS)
set(NBL_TARGET_MSVC_DEBUG_INFORMATION_FORMAT "$<$<OR:$<STREQUAL:${MAPPED_CONFIG},DEBUG>,$<STREQUAL:${MAPPED_CONFIG},RELWITHDEBINFO>>:ProgramDatabase>")
else()
Expand Down
45 changes: 45 additions & 0 deletions cmake/adjust/template/vendor/CXX_Clang.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
include_guard(GLOBAL)

# Debug

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about macro definitions like NDEBUG ?

P.S. should MSVC even define should macros from commandline instead of configuring theminto the header?

Copy link
Member

@AnastaZIuk AnastaZIuk Apr 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about macro definitions like NDEBUG ?

in theory we set them in MSVC frontend profile but we could skip doing so both for this profile & Clang since CMake sets NDEBUG at the very beginning with CMAKE_<LANG>_FLAGS_<CONFIG>_INIT within some defaults (ofc, it can be overwritten)

instead of configuring theminto the header?

to be discussed but we already generate a set of defines which is included in nabla.h iirc, we could remove defines from CLI

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a2a7e72 I stay at defining it myself though

set(NBL_CXX_DEBUG_COMPILE_OPTIONS
-ggdb3 -Wall -fno-omit-frame-pointer -fstack-protector-strong

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is ggdb3 sufficient?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't -g also be used?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw GCC/Clang have an equivalent of ffast math that we use in MSVC

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually ggdb3 doesn't exist on clang and it throws a warning about unknown arg

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I swear it was a GCC / Emscripten thing

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also ggdb3 is for GDB, I think on Clang one is supposed to use LLDB

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on windows ClangCL which is Clang frontend compatible with MSVC CLI uses lld-link linker

C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\Llvm\bin>lld.exe
lld is a generic driver.
Invoke ld.lld (Unix), ld64.lld (macOS), lld-link (Windows), wasm-ld (WebAssembly) instead

)

# Release
set(NBL_CXX_RELEASE_COMPILE_OPTIONS
-fexpensive-optimizations
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think O3 enables this by default ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes however -fexpensive-optimizations is not Clang's option but GCC's


# RelWithDebInfo
set(NBL_CXX_RELWITHDEBINFO_COMPILE_OPTIONS "")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about O1 or something ? Alos don't you need ggdb3 ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or even O2

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about O1 or something ? Alos don't you need ggdb3 ?

#791 (comment) + resolved


# Global
list(APPEND NBL_CXX_COMPILE_OPTIONS
-Wextra
-fno-strict-aliasing
-msse4.2

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mavx

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you might also need a flag for stripping debug symbols

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mavx

resolved

-mfpmath=sse
-Wextra
-Wno-sequence-point
-Wno-unused-parameter
-Wno-unused-but-set-parameter
-Wno-error=ignored-attributes
-Wno-error=unused-function
-Wno-error=unused-variable
-Wno-error=unused-parameter
-Wno-error=ignored-attributes
-Wno-error=non-pod-varargs
-fno-exceptions

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think we can compile without exceptions, there are some try-catch block in our code IIRC ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think we can compile without exceptions, there are some try-catch block in our code IIRC ?

resolved, -fno-exceptions should not be there + its possible to compile with this flag but it changes runtime behaviour which we don't want (asserts)

)

if(NBL_SANITIZE_ADDRESS)
list(APPEND NBL_CXX_COMPILE_OPTIONS -fsanitize=address)
endif()

if(NBL_SANITIZE_THREAD)
list(APPEND NBL_CXX_COMPILE_OPTIONS -fsanitize=thread)
endif()

# our pervious flags-set function called this, does not affect flags nor configs so I will keep it here temporary
# TODO: move it out from the profile
link_libraries(-fuse-ld=gold)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about incremental linking and stuff?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved, we use incremental linking

42 changes: 42 additions & 0 deletions cmake/adjust/template/vendor/CXX_MSVC.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
include_guard(GLOBAL)

# https://learn.microsoft.com/en-us/cpp/build/reference/arch-x64?view=msvc-170

# The default instruction set is SSE2 if no /arch option is specified.
if(NBL_REQUEST_SSE_4_2)
NBL_REQUEST_COMPILE_OPTION_SUPPORT("/arch:SSE4.2")
endif()

# Enables Intel Advanced Vector Extensions 2.
if(NBL_REQUEST_SSE_AXV2)
NBL_REQUEST_COMPILE_OPTION_SUPPORT("/arch:AVX2")
endif()

# Debug
set(NBL_CXX_DEBUG_COMPILE_OPTIONS
/Zc:__cplusplus /Ob0 /Od /MP${_NBL_JOBS_AMOUNT_} /fp:fast /Zc:wchar_t /INCREMENTAL
)

if(NBL_SANITIZE_ADDRESS)
list(APPEND NBL_CXX_DEBUG_COMPILE_OPTIONS /RTC1)
endif()

# Release
set(NBL_CXX_RELEASE_COMPILE_OPTIONS
/Zc:__cplusplus /O2 /Ob2 /DNDEBUG /GL /MP${_NBL_JOBS_AMOUNT_} /Gy- /Zc:wchar_t /sdl- /GF /GS- /fp:fast
)

# RelWithDebInfo
set(NBL_CXX_RELWITHDEBINFO_COMPILE_OPTIONS
/Zc:__cplusplus /O2 /Ob1 /DNDEBUG /GL /Zc:wchar_t /MP${_NBL_JOBS_AMOUNT_} /Gy /sdl- /Oy- /fp:fast
)

if(NBL_SANITIZE_ADDRESS)
list(APPEND NBL_CXX_COMPILE_OPTIONS /fsanitize=address)
endif()

# this should also be not part of profile, pasting from old flags-set function temporary
# TODO: use profile

#reason for INCREMENTAL:NO: https://docs.microsoft.com/en-us/cpp/build/reference/ltcg-link-time-code-generation?view=vs-2019 /LTCG is not valid for use with /INCREMENTAL.
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /INCREMENTAL:NO /LTCG:incremental")
46 changes: 46 additions & 0 deletions cmake/adjust/template/vendor/C_Clang.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
include_guard(GLOBAL)

# Debug
set(NBL_C_DEBUG_COMPILE_OPTIONS
-ggdb3 -Wall -fno-omit-frame-pointer -fstack-protector-strong
)

# Release
set(NBL_C_RELEASE_COMPILE_OPTIONS
-fexpensive-optimizations
)

# RelWithDebInfo
set(NBL_C_RELWITHDEBINFO_COMPILE_OPTIONS "")

# Global
list(APPEND NBL_C_COMPILE_OPTIONS
-Wextra
-fno-strict-aliasing
-msse4.2
-mfpmath=sse
-maes
-Wextra
-Wno-sequence-point
-Wno-unused-parameter
-Wno-unused-but-set-parameter
-Wno-error=ignored-attributes
-Wno-error=unused-function
-Wno-error=unused-variable
-Wno-error=unused-parameter
-Wno-error=ignored-attributes
-Wno-error=non-pod-varargs
-fno-exceptions
)

if(NBL_SANITIZE_ADDRESS)
list(APPEND NBL_C_COMPILE_OPTIONS -fsanitize=address)
endif()

if(NBL_SANITIZE_THREAD)
list(APPEND NBL_C_COMPILE_OPTIONS -fsanitize=thread)
endif()

# our pervious flags-set function called this, does not affect flags nor configs so I will keep it here temporary
# TODO: move it out from the profile
link_libraries(-fuse-ld=gold)
Original file line number Diff line number Diff line change
Expand Up @@ -21,51 +21,20 @@ if(NBL_SANITIZE_ADDRESS)
list(APPEND NBL_C_DEBUG_COMPILE_OPTIONS /RTC1)
endif()

set(NBL_CXX_DEBUG_COMPILE_OPTIONS
/Zc:__cplusplus ${NBL_C_DEBUG_COMPILE_OPTIONS}
)

set(NBL_DEBUG_COMPILE_OPTIONS
$<$<COMPILE_LANGUAGE:CXX>:${NBL_CXX_DEBUG_COMPILE_OPTIONS}>
$<$<COMPILE_LANGUAGE:C>:${NBL_C_DEBUG_COMPILE_OPTIONS}>
)

# Release
set(NBL_C_RELEASE_COMPILE_OPTIONS
/O2 /Ob2 /DNDEBUG /GL /MP${_NBL_JOBS_AMOUNT_} /Gy- /Zc:wchar_t /sdl- /GF /GS- /fp:fast
)
set(NBL_CXX_RELEASE_COMPILE_OPTIONS
/Zc:__cplusplus ${NBL_C_RELEASE_COMPILE_OPTIONS}
)

set(NBL_RELEASE_COMPILE_OPTIONS
$<$<COMPILE_LANGUAGE:CXX>:${NBL_CXX_RELEASE_COMPILE_OPTIONS}>
$<$<COMPILE_LANGUAGE:C>:${NBL_C_RELEASE_COMPILE_OPTIONS}>
)

# RelWithDebInfo
set(NBL_C_RELWITHDEBINFO_COMPILE_OPTIONS
/O2 /Ob1 /DNDEBUG /GL /Zc:wchar_t /MP${_NBL_JOBS_AMOUNT_} /Gy /sdl- /Oy- /fp:fast
)
set(NBL_CXX_RELWITHDEBINFO_COMPILE_OPTIONS
/Zc:__cplusplus ${NBL_C_RELWITHDEBINFO_COMPILE_OPTIONS}
)

set(NBL_RELWITHDEBINFO_COMPILE_OPTIONS
$<$<COMPILE_LANGUAGE:CXX>:${NBL_CXX_RELWITHDEBINFO_COMPILE_OPTIONS}>
$<$<COMPILE_LANGUAGE:C>:${NBL_C_RELWITHDEBINFO_COMPILE_OPTIONS}>
)

if(NBL_SANITIZE_ADDRESS)
list(APPEND NBL_C_COMPILE_OPTIONS /fsanitize=address)
list(APPEND NBL_CXX_COMPILE_OPTIONS ${NBL_C_COMPILE_OPTIONS})
endif()

set(NBL_COMPILE_OPTIONS
$<$<COMPILE_LANGUAGE:CXX>:${NBL_CXX_COMPILE_OPTIONS}>
$<$<COMPILE_LANGUAGE:C>:${NBL_C_COMPILE_OPTIONS}>
)

# this should also be not part of profile, pasting from old flags-set function temporary
# TODO: use profile

Expand Down
Loading