BLT/cmake/warnings.cmake

35 lines
1.9 KiB
CMake

if(NOT WIN32)
string(ASCII 27 Esc)
set(ColourReset "${Esc}[m")
set(Blue "${Esc}[34m")
set(Green "${Esc}[32m")
endif ()
message("Enabling platform specific compile options for ${Blue}${PROJECT_NAME}${ColourReset}")
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# using Clang
message(STATUS "Clang Compile: ${Green}-Wall -Wextra -Wpedantic -Weverything -fdiagnostics-color=always${ColourReset}")
message(STATUS "Clang Link: ${Green}-export_dynamic${ColourReset}")
message(STATUS "Clang libs: ${Green}stdc++fs${ColourReset}")
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -fdiagnostics-color=always)
target_link_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -fdiagnostics-color=always)
target_link_options(${PROJECT_NAME} PUBLIC -export_dynamic -rdynamic)
target_link_libraries(${PROJECT_NAME} PUBLIC stdc++fs)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# using GCC
message(STATUS "GCC Compile: ${Green}-Wall -Wextra -Wpedantic -fdiagnostics-color=always${ColourReset}")
message(STATUS "GCC Link: ${Green}-rdynamic${ColourReset}")
message(STATUS "GCC libs: ${Green}stdc++fs${ColourReset}")
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -fdiagnostics-color=always)
target_link_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wpedantic -fdiagnostics-color=always)
target_link_options(${PROJECT_NAME} PUBLIC -rdynamic)
target_link_libraries(${PROJECT_NAME} PUBLIC stdc++fs)
include(GNUInstallDirs)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
# using Intel C++
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# using Visual Studio C++
message(STATUS "MSVC Compile: ${Green}/Wall${ColourReset}")
message(STATUS "MSVC Link: ${Green}${ColourReset}")
message(STATUS "MSVC libs: ${Green}${ColourReset}")
target_compile_options(${PROJECT_NAME} PUBLIC /Wall)
endif ()