Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,30 @@ ENDIF(NOT DEFINED CMAKE_INSTALL_PREFIX)
SET(TARGET_COPY_FILES "" CACHE INTERNAL "" FORCE)
SET(TARGET_COPY_DIRS "" CACHE INTERNAL "" FORCE)

### Define options and editable variables in the section below:
# This is only needed for single configuration generators so don't annoy others
if(NOT CMAKE_BUILD_TYPE AND NOT DEFINED CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Default build configuration used." FORCE)
message(WARNING "CMAKE_BUILD_TYPE was not specified, defaulting to Release configuration.")
endif(NOT CMAKE_BUILD_TYPE AND NOT DEFINED CMAKE_CONFIGURATION_TYPES)
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)

# Override standard CMake configurations
set(CMAKE_CONFIGURATION_TYPES Debug Release FastDebug CACHE STRING "Available configurations" FORCE)
set(FSO_BUILD_TYPES Debug Release FastDebug)

if(is_multi_config)
Comment thread
Goober5000 marked this conversation as resolved.
set(CMAKE_CONFIGURATION_TYPES "${FSO_BUILD_TYPES}" CACHE STRING "Configuration types" FORCE)
elseif(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Default build configuration used." FORCE)
message(WARNING "CMAKE_BUILD_TYPE was not specified, defaulting to Release configuration.")
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${FSO_BUILD_TYPES}")
endif()

set(FSO_LANGUAGES C CXX)

if(APPLE)
set(FSO_LANGUAGES ${FSO_LANGUAGES} OBJC OBJCXX)

# 10.15 for c++17 std::filesystem
# NOTE: this must be set *before* the project() call to work properly!!
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "macOS deployment target")
Comment thread
Goober5000 marked this conversation as resolved.

# fix all targets in scheme (so it's not just qtfred)
set(CMAKE_XCODE_GENERATE_SCHEME TRUE)
endif()

PROJECT(FS2_Open LANGUAGES ${FSO_LANGUAGES})
Expand Down Expand Up @@ -196,11 +206,11 @@ include(clang-tidy)

include(CheckIPOSupported)
check_ipo_supported(RESULT LTO_AVAILABLE)
if (CMAKE_BUILD_TYPE STREQUAL "Release" AND FSO_USE_LTO AND LTO_AVAILABLE)
if (FSO_USE_LTO AND LTO_AVAILABLE)
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
message("Enabled LTO")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif (CMAKE_BUILD_TYPE STREQUAL "Release" AND FSO_USE_LTO AND LTO_AVAILABLE)
message("Enabled LTO for Release builds")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE)
Comment thread
Goober5000 marked this conversation as resolved.
endif (FSO_USE_LTO AND LTO_AVAILABLE)

# This includes source code for some tools, either used in the build or also for something else
ADD_SUBDIRECTORY(tools)
Expand Down
4 changes: 0 additions & 4 deletions cmake/platform-darwin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ endif()

target_link_libraries(platform INTERFACE ${COCOA_LIBRARY})

# To support C++17 we need to target at least 10.13. maybe 10.14 for some rare features
# bump to 10.15 for c++17 std::filesystem usage in qtFRED
SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.15")

SET(CMAKE_SKIP_RPATH FALSE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
SET(CMAKE_INSTALL_RPATH @loader_path/../Frameworks/)
Expand Down
11 changes: 11 additions & 0 deletions cmake/util.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,17 @@ function(suppress_file_warnings)
endif()
endfunction(suppress_file_warnings)

# Suppress no symbols warnings in static libraries (on Xcode)
function(suppress_no_symbol_warnings _target)
if(XCODE)
get_target_property(target_type ${_target} TYPE)
if(target_type STREQUAL "STATIC_LIBRARY")
set_property(TARGET ${_target} APPEND PROPERTY
STATIC_LIBRARY_OPTIONS "-no_warning_for_no_symbols"
)
endif()
endif()
endfunction(suppress_no_symbol_warnings)

function(list_target_dependencies _target _out_var)
set(out_list)
Expand Down
3 changes: 3 additions & 0 deletions code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,8 @@ set_target_properties(code PROPERTIES XCODE_ATTRIBUTE_COPY_PHASE_STRIP[variant=D
set_target_properties(code PROPERTIES XCODE_ATTRIBUTE_STRIP_INSTALLED_PRODUCT[variant=Debug] "NO")
set_target_properties(code PROPERTIES XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN[variant=Debug] "NO")

# Prevent warnings on files with no symbols on Mac
suppress_no_symbol_warnings(code)

# Prevent GCC warnings in third-party BitOp... see GitHub #4366
suppress_file_warnings(scripting/lua/bitop/bit.c)
6 changes: 6 additions & 0 deletions freespace2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,9 @@ set_target_properties(Freespace2 PROPERTIES XCODE_ATTRIBUTE_GCC_GENERATE_DEBUGGI
set_target_properties(Freespace2 PROPERTIES XCODE_ATTRIBUTE_COPY_PHASE_STRIP[variant=Debug] "NO")
set_target_properties(Freespace2 PROPERTIES XCODE_ATTRIBUTE_STRIP_INSTALLED_PRODUCT[variant=Debug] "NO")
set_target_properties(Freespace2 PROPERTIES XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN[variant=Debug] "NO")

set_target_properties(Freespace2 PROPERTIES XCODE_SCHEME_ARGUMENTS "${FSO_RUN_ARGUMENTS}")
Comment thread
Goober5000 marked this conversation as resolved.

if(FSO_FREESPACE_PATH AND NOT "${FSO_FREESPACE_PATH}" STREQUAL "${CMAKE_INSTALL_PREFIX}")
Comment thread
Goober5000 marked this conversation as resolved.
set_target_properties(Freespace2 PROPERTIES XCODE_SCHEME_WORKING_DIRECTORY "${FSO_FREESPACE_PATH}")
endif()
5 changes: 3 additions & 2 deletions freespace2/resources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ elseif(PLATFORM_MAC)
set_target_properties(Freespace2 PROPERTIES MACOSX_BUNDLE_LONG_VERSION_STRING "${FSO_FULL_VERSION_STRING}")
set_target_properties(Freespace2 PROPERTIES MACOSX_BUNDLE_SHORT_VERSION_STRING "${FSO_PRODUCT_VERSION_STRING}")
set_target_properties(Freespace2 PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "FreeSpace Open")
set_target_properties(Freespace2 PROPERTIES MACOSX_DEPLOYMENT_TARGET "${CMAKE_OSX_DEPLOYMENT_TARGET}")
set_target_properties(Freespace2 PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER "us.indiegames.scp.FreeSpaceOpen")


set_target_properties(Freespace2 PROPERTIES XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "us.indiegames.scp.FreeSpaceOpen")

# Copy everything from the Resources directory
add_custom_command(TARGET Freespace2 POST_BUILD
COMMAND cp -a "${CMAKE_CURRENT_SOURCE_DIR}/${subpath}/Resources" "$<TARGET_FILE_DIR:Freespace2>/../Resources"
Expand Down
2 changes: 1 addition & 1 deletion freespace2/resources/mac/Info.plist.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<key>LSApplicationCategoryType</key>
<string>public.app-category.games</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<string>${CMAKE_OSX_DEPLOYMENT_TARGET}</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
Expand Down
7 changes: 4 additions & 3 deletions lib/antlr4-cpp-runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ set(CMAKE_MACOSX_RPATH OFF)

set(ANTLR_BUILD_SHARED OFF)

# Detect build type, fallback to release and throw a warning if use didn't specify any
if(NOT CMAKE_BUILD_TYPE)
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)

if(NOT CMAKE_BUILD_TYPE AND NOT is_multi_config)
message(WARNING "Build type not set, falling back to Release mode.
To specify build type use:
-DCMAKE_BUILD_TYPE=<mode> where <mode> is Debug or Release.")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, options are: Debug Release."
FORCE)
endif(NOT CMAKE_BUILD_TYPE)
endif(NOT CMAKE_BUILD_TYPE AND NOT is_multi_config)

if(NOT WITH_DEMO)
message(STATUS "Building without demo. To enable demo build use: -DWITH_DEMO=True")
Expand Down
3 changes: 3 additions & 0 deletions lib/antlr4.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ add_subdirectory(antlr4-cpp-runtime EXCLUDE_FROM_ALL)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/antlr4-cpp-runtime/cmake" PARENT_SCOPE)
suppress_warnings(antlr4_static)

# Prevent warnings on files with no symbols on Mac
suppress_no_symbol_warnings(antlr4_static)

target_include_directories(antlr4_static PUBLIC "${CMAKE_CURRENT_LIST_DIR}/antlr4-cpp-runtime/runtime/src")
Comment thread
Goober5000 marked this conversation as resolved.

set_target_properties(antlr4_static
Expand Down
3 changes: 3 additions & 0 deletions parsers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@ add_parser(action_expression/ActionExpression.g4)
target_include_directories(parsers PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")

suppress_warnings(parsers)

# Prevent warnings on files with no symbols on Mac
suppress_no_symbol_warnings(parsers)
8 changes: 7 additions & 1 deletion qtfred/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,16 @@ elseif(PLATFORM_MAC)
set_target_properties(qtfred PROPERTIES MACOSX_BUNDLE_LONG_VERSION_STRING "${FSO_FULL_VERSION_STRING}")
set_target_properties(qtfred PROPERTIES MACOSX_BUNDLE_SHORT_VERSION_STRING "${FSO_PRODUCT_VERSION_STRING}")
set_target_properties(qtfred PROPERTIES MACOSX_BUNDLE_BUNDLE_NAME "qtFRED")
set_target_properties(qtfred PROPERTIES MACOSX_DEPLOYMENT_TARGET "${CMAKE_OSX_DEPLOYMENT_TARGET}")
set_target_properties(qtfred PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER "us.indiegames.scp.qtFRED")

set_target_properties(qtfred PROPERTIES XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "us.indiegames.scp.qtFRED")
set_target_properties(qtfred PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_STYLE "Manual")
set_target_properties(qtfred PROPERTIES XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")
set_target_properties(qtfred PROPERTIES XCODE_SCHEME_ARGUMENTS "${FSO_RUN_ARGUMENTS}")
Comment thread
Goober5000 marked this conversation as resolved.

if(FSO_FREESPACE_PATH AND NOT "${FSO_FREESPACE_PATH}" STREQUAL "${CMAKE_INSTALL_PREFIX}")
set_target_properties(qtfred PROPERTIES XCODE_SCHEME_WORKING_DIRECTORY "${FSO_FREESPACE_PATH}")
endif()

# Copy everything from the Resources directory
add_custom_command(TARGET qtfred POST_BUILD
Expand Down
2 changes: 1 addition & 1 deletion qtfred/resources/mac/Info.plist.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<key>LSApplicationCategoryType</key>
<string>public.app-category.games</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<string>${CMAKE_OSX_DEPLOYMENT_TARGET}</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
Expand Down
Loading