summaryrefslogtreecommitdiff
path: root/indra/cmake/00-Common.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'indra/cmake/00-Common.cmake')
-rw-r--r--indra/cmake/00-Common.cmake106
1 files changed, 68 insertions, 38 deletions
diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake
index 4c98983df5..7de12d0063 100644
--- a/indra/cmake/00-Common.cmake
+++ b/indra/cmake/00-Common.cmake
@@ -15,6 +15,7 @@
include_guard()
include(Variables)
+include(Linker)
# We go to some trouble to set LL_BUILD to the set of relevant compiler flags.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} $ENV{LL_BUILD}")
@@ -110,59 +111,97 @@ if (WINDOWS)
add_compile_definitions(_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR)
endif (WINDOWS)
-
if (LINUX OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
- set(CMAKE_SKIP_RPATH TRUE)
-
- # EXTERNAL_TOS
- # force this platform to accept TOS via external browser
+ set( CMAKE_BUILD_WITH_INSTALL_RPATH TRUE )
+ set( CMAKE_INSTALL_RPATH $ORIGIN $ORIGIN/../lib )
+ set(CMAKE_EXE_LINKER_FLAGS "-Wl,--exclude-libs,ALL")
+
+ find_program(CCACHE_EXE ccache)
+ if(CCACHE_EXE AND NOT DISABLE_CCACHE)
+ set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_EXE} )
+ set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_EXE} )
+ endif()
- # LL_IGNORE_SIGCHLD
- # don't catch SIGCHLD in our base application class for the viewer - some of
- # our 3rd party libs may need their *own* SIGCHLD handler to work. Sigh! The
- # viewer doesn't need to catch SIGCHLD anyway.
+ # LL_IGNORE_SIGCHLD
+ # don't catch SIGCHLD in our base application class for the viewer - some of
+ # our 3rd party libs may need their *own* SIGCHLD handler to work. Sigh! The
+ # viewer doesn't need to catch SIGCHLD anyway.
add_compile_definitions(
_REENTRANT
- _FORTIFY_SOURCE=2
- APPID=secondlife
+ APPID=megapahit
LL_IGNORE_SIGCHLD
)
+ if( ENABLE_ASAN )
+ add_compile_options(-U_FORTIFY_SOURCE
+ -fsanitize=address
+ --param asan-stack=0
+ )
+ add_link_options(-fsanitize=address)
+ else()
+ add_compile_definitions( _FORTIFY_SOURCE=2 )
+ endif()
+
if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
add_compile_definitions(EXTERNAL_TOS)
endif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
add_compile_options(
- -fexceptions
- -fno-math-errno
- -fno-strict-aliasing
- -fsigned-char
- -msse2
- -mfpmath=sse
- -pthread
- -Wno-parentheses
- -Wno-deprecated
- -Wno-c++20-compat
+ -fexceptions
+ -fno-math-errno
+ -fno-strict-aliasing
+ -fsigned-char
+ -msse2
+ -mfpmath=sse
+ -pthread
)
if (NOT BUILD_SHARED_LIBS)
add_compile_options(-fvisibility=hidden)
endif (NOT BUILD_SHARED_LIBS)
- if (ADDRESS_SIZE EQUAL 32)
- add_compile_options(-march=pentium4)
- endif (ADDRESS_SIZE EQUAL 32)
+ set(GCC_CLANG_COMPATIBLE_WARNINGS
+ -Wno-parentheses
+ -Wno-deprecated
+ -Wno-c++20-compat
+ -Wno-pessimizing-move
+ )
+
+ set(CLANG_WARNINGS
+ ${GCC_CLANG_COMPATIBLE_WARNINGS}
+ # Put clang specific warning configuration here
+ )
+
+ set(GCC_WARNINGS
+ ${GCC_CLANG_COMPATIBLE_WARNINGS}
+ -Wno-dangling-pointer
+ )
+
+ add_link_options(
+ -Wl,--no-keep-memory
+ -Wl,--build-id
+ -Wl,--no-undefined
+ )
+ if (NOT GCC_DISABLE_FATAL_WARNINGS)
+ add_compile_options( -Werror )
+ endif (NOT GCC_DISABLE_FATAL_WARNINGS)
# this stops us requiring a really recent glibc at runtime
add_compile_options(-fno-stack-protector)
- # linking can be very memory-hungry, especially the final viewer link
- set(CMAKE_CXX_LINK_FLAGS "-Wl,--no-keep-memory")
- set(CMAKE_CXX_FLAGS_DEBUG "-fno-inline ${CMAKE_CXX_FLAGS_DEBUG}")
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ # ND: clang is a bit more picky than GCC, the latter seems to auto include -lstdc++ and -lm. The former not so and thus fails to link
+ add_link_options(
+ -lstdc++
+ -lm
+ )
+ add_compile_options(${CLANG_WARNINGS})
+ else()
+ add_compile_options(${GCC_WARNINGS})
+ endif()
endif (LINUX OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
-
if (DARWIN)
# Warnings should be fatal -- thanks, Nicky Perian, for spotting reversed default
set(CLANG_DISABLE_FATAL_WARNINGS OFF)
@@ -184,15 +223,9 @@ if (DARWIN)
# required for clang-15/xcode-15 since our boost package still uses deprecated std::unary_function/binary_function
# see https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#C++-Standard-Library
add_compile_definitions(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
-endif (DARWIN)
-if (LINUX OR DARWIN)
set(GCC_WARNINGS -Wall -Wno-sign-compare -Wno-trigraphs)
- if (NOT GCC_DISABLE_FATAL_WARNINGS)
- list(APPEND GCC_WARNINGS -Werror)
- endif (NOT GCC_DISABLE_FATAL_WARNINGS)
-
list(APPEND GCC_WARNINGS -Wno-reorder -Wno-non-virtual-dtor )
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13)
@@ -201,7 +234,4 @@ if (LINUX OR DARWIN)
add_compile_options(${GCC_WARNINGS})
add_compile_options(-m${ADDRESS_SIZE})
-endif (LINUX OR DARWIN)
-
-
-
+endif ()