Skip to content

Commit

Permalink
feat(cmake): support regular clang compiling on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Milerius committed Oct 27, 2019
1 parent 1445f33 commit 4797a3b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
13 changes: 13 additions & 0 deletions cmake/antara.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ macro(configure_icon_osx icon_path icon_variable icon_name)
endif ()
endmacro()

macro(init_windows_env)
if (WIN32)
message(STATUS "${CMAKE_CXX_COMPILER_ID} x${CMAKE_CXX_SIMULATE_ID} ${CMAKE_CXX_COMPILER}")
get_filename_component(real_compiler ${CMAKE_CXX_COMPILER} NAME_WE)
if (${real_compiler} STREQUAL "clang-cl")
set(ClangCL ON)
message(STATUS "clang cl detected")
endif()
endif()
endmacro()

init_windows_env()

include(compiler_targets)
include(dependencies)

Expand Down
11 changes: 8 additions & 3 deletions cmake/compiler_targets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ target_compile_options(
INTERFACE
$<$<AND:$<PLATFORM_ID:Linux>,$<CXX_COMPILER_ID:Clang>>:-Wall -Wextra -Wfatal-errors>
$<$<AND:$<PLATFORM_ID:Darwin>,$<CXX_COMPILER_ID:Clang>>:-Wall -Wextra -Wfatal-errors>
$<$<AND:$<PLATFORM_ID:Windows>,$<CXX_COMPILER_ID:Clang>>:/W4 /permissive->)
$<$<AND:$<PLATFORM_ID:Windows>,$<NOT:$<BOOL:${ClangCL}>>,$<CXX_COMPILER_ID:Clang>>:-Wall -Wextra -Wfatal-errors>
$<$<AND:$<PLATFORM_ID:Windows>,$<BOOL:${ClangCL}>,$<CXX_COMPILER_ID:Clang>>:/W4 /permissive->)

# $<$<AND:$<PLATFORM_ID:Windows>,$<NOT:$<BOOL:${ClangCL}>>,$<CXX_COMPILER_ID:Clang>>:-Wall -Wextra -Wfatal-errors>
# $<$<AND:$<PLATFORM_ID:Windows>,$<BOOL:${ClangCL}>,$<CXX_COMPILER_ID:Clang>>:/W4 /permissive->
##! We are using C++ 17 for all of our targets
add_library(antara_defaults_features INTERFACE)
add_library(antara::defaults_features ALIAS antara_defaults_features)
Expand All @@ -34,8 +37,10 @@ target_compile_options(antara_optimize_settings INTERFACE
$<$<AND:$<CONFIG:Release>,$<CXX_COMPILER_ID:Clang>,$<PLATFORM_ID:Linux>>:-O2 -march=native>
$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:Clang>,$<PLATFORM_ID:Darwin>>:-O0 -g>
$<$<AND:$<CONFIG:Release>,$<CXX_COMPILER_ID:Clang>,$<PLATFORM_ID:Darwin>>:-O2 -march=native>
$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:Clang>,$<PLATFORM_ID:Windows>>:/Zi /FS /DEBUG /Od /MDd /Oy->
$<$<AND:$<CONFIG:Release>,$<CXX_COMPILER_ID:Clang>,$<PLATFORM_ID:Windows>>:/O2 -DNDEBUG>
$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:Clang>,$<PLATFORM_ID:Windows>,$<NOT:$<BOOL:${ClangCL}>>>:-O0 -g>
$<$<AND:$<CONFIG:Release>,$<CXX_COMPILER_ID:Clang>,$<PLATFORM_ID:Windows>,$<NOT:$<BOOL:${ClangCL}>>>:-O2 -march=native>
$<$<AND:$<CONFIG:Debug>,$<CXX_COMPILER_ID:Clang>,$<PLATFORM_ID:Windows>,$<BOOL:${ClangCL}>>:/Zi /FS /DEBUG /Od /MDd /Oy->
$<$<AND:$<CONFIG:Release>,$<CXX_COMPILER_ID:Clang>,$<PLATFORM_ID:Windows>,$<BOOL:${ClangCL}>>:/O2 -DNDEBUG>
)

## Cross filesystem
Expand Down

0 comments on commit 4797a3b

Please sign in to comment.