2017-01-25 18:46:41 +11:00
|
|
|
###############################################################################
|
|
|
|
if (__nc_cxx)
|
|
|
|
return ()
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
set (__nc_cxx TRUE)
|
|
|
|
|
2017-05-12 14:56:47 +10:00
|
|
|
###############################################################################
|
|
|
|
# clear the default flags because they include optimisation flags we
|
|
|
|
# explicitly do not want (ie, O3).
|
|
|
|
set (CMAKE_CXX_FLAGS_RELEASE "")
|
|
|
|
set (CMAKE_C_FLAGS_RELEASE "")
|
|
|
|
set (CMAKE_CXX_FLAGS_DEBUG "")
|
|
|
|
set (CMAKE_C_FLAGS_DEBUG "")
|
|
|
|
|
2017-01-25 18:46:41 +11:00
|
|
|
|
|
|
|
###############################################################################
|
2017-01-17 19:20:12 +11:00
|
|
|
include (compile_flag)
|
2019-11-04 11:17:09 +11:00
|
|
|
include (link_flag)
|
2017-01-17 19:20:12 +11:00
|
|
|
include (test_restrict)
|
|
|
|
|
|
|
|
|
2018-03-22 15:08:16 +11:00
|
|
|
###############################################################################
|
2019-11-04 11:26:04 +11:00
|
|
|
append_compile_flag ("-fdiagnostics-color=auto")
|
2018-03-22 15:08:16 +11:00
|
|
|
|
|
|
|
|
2017-01-17 19:20:12 +11:00
|
|
|
###############################################################################
|
2018-05-05 14:37:58 +10:00
|
|
|
append_compile_flag ("-std=c++2a")
|
2017-01-23 14:55:07 +11:00
|
|
|
append_compile_flag ("-fpermissive")
|
|
|
|
append_compile_flag ("/std:c++latest")
|
2017-01-17 19:20:12 +11:00
|
|
|
|
2017-08-07 12:55:50 +10:00
|
|
|
# try to use clangs libc++ under the assumption that gcc will fail this test
|
|
|
|
# and clang will pass (if it is present). this is necessary because some
|
|
|
|
# libstdc++ headers don't behave well under c++17/clang.
|
|
|
|
append_compile_flag ("-stdlib=libc++")
|
2017-01-17 19:20:12 +11:00
|
|
|
|
2019-05-06 13:02:15 +10:00
|
|
|
###############################################################################
|
|
|
|
# find the gcc or clang filesystem library and append to libs if needed
|
|
|
|
#
|
|
|
|
# note, we specifically _cannot_ use find_library because it just makes wild
|
|
|
|
# hardcoded guess and doesn't respect _all_ the system paths; specifically
|
|
|
|
# something like /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.0/libstdc++.so won't get
|
|
|
|
# discovered.
|
2019-10-22 12:00:50 +11:00
|
|
|
#if (NOT DEFINED __nc_cxx_stdcxxfs)
|
|
|
|
# foreach(lib "" "c++fs" "c++experimental" "stdc++fs")
|
|
|
|
# message (STATUS "Trying c++fs library '${lib}'")
|
|
|
|
# try_compile(
|
|
|
|
# __nc_cxx_stdcxxfs ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
# SOURCES
|
|
|
|
# ${NC_CMAKE_BASE}/nc_cxx_stdcxxfs.cpp
|
|
|
|
# LINK_LIBRARIES
|
|
|
|
# ${lib}
|
|
|
|
# )
|
|
|
|
#
|
|
|
|
# if (__nc_cxx_stdcxxfs)
|
|
|
|
# set (__nc_cxx_stdcxxfs "${lib}" CACHE INTERNAL "library required for c++ filesystem")
|
|
|
|
# break ()
|
|
|
|
# endif ()
|
|
|
|
# endforeach()
|
|
|
|
#
|
|
|
|
# if (NOT DEFINED __nc_cxx_stdcxxfs)
|
|
|
|
# message (FATAL_ERROR "Could not locate the required c++fs library")
|
|
|
|
# endif ()
|
|
|
|
#
|
|
|
|
# message (STATUS "Using c++fs library ${__nc_cxx_stdcxxfs}")
|
|
|
|
#endif ()
|
2019-05-06 13:02:15 +10:00
|
|
|
|
|
|
|
set(NC_CXX_STDCXXFS ${__nc_cxx_stdcxxfs})
|
|
|
|
|
2017-01-17 19:20:12 +11:00
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
test_restrict(RESTRICT_KEYWORD)
|
|
|
|
add_definitions("-Drestrict=${RESTRICT_KEYWORD}")
|
|
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
append_compile_flag("-pipe")
|
|
|
|
append_compile_flag("-fno-deduce-init-list")
|
|
|
|
append_compile_flag("-fvisibility=hidden")
|
2019-10-31 17:03:51 +11:00
|
|
|
append_compile_flag("-fvisibility-inlines-hidden")
|
2019-03-03 13:00:27 +11:00
|
|
|
append_compile_flag("-fPIC")
|
2018-08-13 14:55:45 +10:00
|
|
|
|
2019-11-04 11:17:09 +11:00
|
|
|
# We want a build-id so that we can attribute minidumps
|
|
|
|
append_link_flag("-Wl,--build-id")
|
|
|
|
|
2018-08-13 14:55:45 +10:00
|
|
|
append_compile_flag("-D__STDC_FORMAT_MACROS")
|
2019-01-04 17:18:07 +11:00
|
|
|
|
|
|
|
add_definitions("-D_FILE_OFFSET_BITS=64")
|