summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRye <rye@lindenlab.com>2025-01-21 01:20:11 -0500
committerRye <rye@lindenlab.com>2025-02-11 05:04:05 -0500
commit51ed6b5424a626499ddb7f95e6da7cf34b375f6a (patch)
treef031da0987b99682d00f0670731d4e5dbaec8d02
parent635c34a17bad6435f6981163660947dbf13ee763 (diff)
Update to use universal build flags and fix cmake deprecations
-rw-r--r--indra/cmake/00-Common.cmake50
-rw-r--r--indra/cmake/Linking.cmake1
-rw-r--r--indra/cmake/Variables.cmake48
-rw-r--r--indra/doxygen/CMakeLists.txt14
-rw-r--r--indra/llwindow/CMakeLists.txt7
5 files changed, 39 insertions, 81 deletions
diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake
index 39f26ced5d..69eeff0a79 100644
--- a/indra/cmake/00-Common.cmake
+++ b/indra/cmake/00-Common.cmake
@@ -155,46 +155,40 @@ if (LINUX)
set(CMAKE_CXX_FLAGS_DEBUG "-fno-inline ${CMAKE_CXX_FLAGS_DEBUG}")
endif (LINUX)
-
if (DARWIN)
+ # Use rpath loading on macos
+ set(CMAKE_MACOSX_RPATH TRUE)
+
# Warnings should be fatal -- thanks, Nicky Perian, for spotting reversed default
set(CLANG_DISABLE_FATAL_WARNINGS OFF)
set(CMAKE_CXX_LINK_FLAGS "-Wl,-headerpad_max_install_names,-search_paths_first")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_LINK_FLAGS}")
- set(DARWIN_extra_cstar_flags "-Wno-unused-local-typedef -Wno-deprecated-declarations")
- # Ensure that CMAKE_CXX_FLAGS has the correct -g debug information format --
- # see Variables.cmake.
- string(REPLACE "-gdwarf-2" "-g${CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT}"
- CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DARWIN_extra_cstar_flags}")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${DARWIN_extra_cstar_flags}")
- # NOTE: it's critical that the optimization flag is put in front.
- # NOTE: it's critical to have both CXX_FLAGS and C_FLAGS covered.
-## Really?? On developer machines too?
-##set(ENABLE_SIGNING TRUE)
-##set(SIGNING_IDENTITY "Developer ID Application: Linden Research, Inc.")
-
- # 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)
+ # Ensure debug symbols are always generated
+ add_compile_options(-g --debug) # --debug is a clang synonym for -g that bypasses cmake behaviors
- if (NOT GCC_DISABLE_FATAL_WARNINGS)
- list(APPEND GCC_WARNINGS -Werror)
- endif (NOT GCC_DISABLE_FATAL_WARNINGS)
+ # Silence GL deprecation warnings
+ add_compile_definitions(GL_SILENCE_DEPRECATION=1)
+endif(DARWIN)
- list(APPEND GCC_WARNINGS -Wno-reorder -Wno-non-virtual-dtor )
+if (LINUX OR DARWIN)
+ add_compile_options(-Wall -Wno-sign-compare -Wno-trigraphs -Wno-reorder -Wno-unused-but-set-variable -Wno-unused-variable)
- if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13)
- list(APPEND GCC_WARNINGS -Wno-unused-but-set-variable -Wno-unused-variable )
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
+ # libstdc++ headers contain deprecated declarations that fail on clang
+ # macOS currently has many deprecated calls
+ add_compile_options(-Wno-unused-local-typedef -Wno-deprecated-declarations)
endif()
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ add_compile_options(-Wno-stringop-truncation -Wno-parentheses -Wno-maybe-uninitialized)
+ endif()
+
+ if (NOT GCC_DISABLE_FATAL_WARNINGS AND NOT CLANG_DISABLE_FATAL_WARNINGS)
+ add_compile_options(-Werror)
+ endif ()
+
add_compile_options(${GCC_WARNINGS})
add_compile_options(-m${ADDRESS_SIZE})
endif (LINUX OR DARWIN)
-
-
diff --git a/indra/cmake/Linking.cmake b/indra/cmake/Linking.cmake
index 1d757abeff..1093fc7f71 100644
--- a/indra/cmake/Linking.cmake
+++ b/indra/cmake/Linking.cmake
@@ -67,7 +67,6 @@ elseif (WINDOWS)
legacy_stdio_definitions
)
else()
- include(CMakeFindFrameworks)
find_library(COREFOUNDATION_LIBRARY CoreFoundation)
find_library(CARBON_LIBRARY Carbon)
find_library(COCOA_LIBRARY Cocoa)
diff --git a/indra/cmake/Variables.cmake b/indra/cmake/Variables.cmake
index 5b3aeb8b7f..a315943a90 100644
--- a/indra/cmake/Variables.cmake
+++ b/indra/cmake/Variables.cmake
@@ -147,49 +147,29 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_OSX_DEPLOYMENT_TARGET "${CMAKE_MATCH_1}")
message(STATUS "CMAKE_OSX_DEPLOYMENT_TARGET = '${CMAKE_OSX_DEPLOYMENT_TARGET}'")
- string(REGEX MATCH "-stdlib=([^ ]+)" scratch "$ENV{LL_BUILD}")
- set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "${CMAKE_MATCH_1}")
- message(STATUS "CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY = '${CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY}'")
-
- string(REGEX MATCH " -g([^ ]*)" scratch "$ENV{LL_BUILD}")
- set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "${CMAKE_MATCH_1}")
- # -gdwarf-2 is passed in LL_BUILD according to 00-COMPILE-LINK-RUN.txt.
- # However, when CMake 3.9.2 sees -gdwarf-2, it silently deletes the whole -g
- # switch, producing no symbols at all! The same thing happens if we specify
- # plain -g ourselves, i.e. CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT is
- # the empty string. Specifying -gdwarf-with-dsym or just -gdwarf drives a
- # different CMake behavior: it substitutes plain -g. As of 2017-09-19,
- # viewer-build-variables/variables still passes -gdwarf-2, which is the
- # no-symbols case. Set -gdwarf, triggering CMake to substitute plain -g --
- # at least that way we should get symbols, albeit mangled ones. It Would Be
- # Nice if CMake's behavior could be predicted from a consistent mental
- # model, instead of only observed experimentally.
- string(REPLACE "dwarf-2" "dwarf"
- CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT
- "${CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT}")
- message(STATUS "CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT = '${CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT}'")
+ # Use dwarf symbols for most libraries for compilation speed
+ set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf")
string(REGEX MATCH "-O([^ ]*)" scratch "$ENV{LL_BUILD}")
set(CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL "${CMAKE_MATCH_1}")
message(STATUS "CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL = '${CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL}'")
# allow disabling this check by setting LL_SKIP_REQUIRE_SYSROOT either ON as cmake cache var or non-empty as environment var
- set(LL_SKIP_REQUIRE_SYSROOT OFF CACHE BOOL "Skip requirement to set toolchain sysroot ahead of time. Not skipped by default for consistency, but skipping can be useful for selecting alternative xcode versions side by side")
- if("$ENV{LL_SKIP_REQUIRE_SYSROOT}" STREQUAL "" AND NOT ${LL_SKIP_REQUIRE_SYSROOT})
- string(REGEX MATCHALL "[^ ]+" LL_BUILD_LIST "$ENV{LL_BUILD}")
- list(FIND LL_BUILD_LIST "-iwithsysroot" sysroot_idx)
- if ("${sysroot_idx}" LESS 0)
- message(FATAL_ERROR "Environment variable LL_BUILD must contain '-iwithsysroot'")
- endif ()
- math(EXPR sysroot_idx "${sysroot_idx} + 1")
- list(GET LL_BUILD_LIST "${sysroot_idx}" CMAKE_OSX_SYSROOT)
- endif()
- message(STATUS "CMAKE_OSX_SYSROOT = '${CMAKE_OSX_SYSROOT}'")
+ # set(LL_SKIP_REQUIRE_SYSROOT OFF CACHE BOOL "Skip requirement to set toolchain sysroot ahead of time. Not skipped by default for consistency, but skipping can be useful for selecting alternative xcode versions side by side")
+ # if("$ENV{LL_SKIP_REQUIRE_SYSROOT}" STREQUAL "" AND NOT ${LL_SKIP_REQUIRE_SYSROOT})
+ # string(REGEX MATCHALL "[^ ]+" LL_BUILD_LIST "$ENV{LL_BUILD}")
+ # list(FIND LL_BUILD_LIST "-iwithsysroot" sysroot_idx)
+ # if ("${sysroot_idx}" LESS 0)
+ # message(FATAL_ERROR "Environment variable LL_BUILD must contain '-iwithsysroot'")
+ # endif ()
+ # math(EXPR sysroot_idx "${sysroot_idx} + 1")
+ # list(GET LL_BUILD_LIST "${sysroot_idx}" CMAKE_OSX_SYSROOT)
+ # endif()
+ # message(STATUS "CMAKE_OSX_SYSROOT = '${CMAKE_OSX_SYSROOT}'")
- set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.llvm.clang.1_0")
set(CMAKE_XCODE_ATTRIBUTE_GCC_STRICT_ALIASING NO)
set(CMAKE_XCODE_ATTRIBUTE_GCC_FAST_MATH NO)
- set(CMAKE_XCODE_ATTRIBUTE_CLANG_X86_VECTOR_INSTRUCTIONS ssse3)
+ set(CMAKE_XCODE_ATTRIBUTE_CLANG_X86_VECTOR_INSTRUCTIONS sse4.2)
# we must hard code this to off for now. xcode's built in signing does not
# handle embedded app bundles such as CEF and others. Any signing for local
# development must be done after the build as we do in viewer_manifest.py for
diff --git a/indra/doxygen/CMakeLists.txt b/indra/doxygen/CMakeLists.txt
index 616b5cd09c..43ebf4ae26 100644
--- a/indra/doxygen/CMakeLists.txt
+++ b/indra/doxygen/CMakeLists.txt
@@ -1,19 +1,5 @@
# -*- cmake -*-
-# cmake_minimum_required should appear before any
-# other commands to guarantee full compatibility
-# with the version specified
-## prior to 2.8, the add_custom_target commands used in setting the version did not work correctly
-cmake_minimum_required(VERSION 3.8.0 FATAL_ERROR)
-
-set(ROOT_PROJECT_NAME "SecondLife" CACHE STRING
- "The root project/makefile/solution name. Defaults to SecondLife.")
-project(${ROOT_PROJECT_NAME})
-
-set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
-
-include(Variables)
-
# add a target to generate API documentation with Doxygen
find_package(Doxygen)
if(DOXYGEN_FOUND)
diff --git a/indra/llwindow/CMakeLists.txt b/indra/llwindow/CMakeLists.txt
index 2996f58fe0..006132b0ba 100644
--- a/indra/llwindow/CMakeLists.txt
+++ b/indra/llwindow/CMakeLists.txt
@@ -63,8 +63,8 @@ set(llwindow_LINK_LIBRARIES
# Libraries on which this library depends, needed for Linux builds
# Sort by high-level to low-level
if (LINUX)
- list(APPEND viewer_SOURCE_FILES
- llkeyboardsdl.cpp
+ list(APPEND viewer_SOURCE_FILES
+ llkeyboardsdl.cpp
llwindowsdl.cpp
)
list(APPEND viewer_HEADER_FILES
@@ -180,9 +180,8 @@ endif (SDL_FOUND)
target_link_libraries (llwindow ${llwindow_LINK_LIBRARIES})
target_include_directories(llwindow INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
-
+
if (DARWIN)
- include(CMakeFindFrameworks)
find_library(CARBON_LIBRARY Carbon)
target_link_libraries(llwindow ${CARBON_LIBRARY})
endif (DARWIN)