[Build] Add toolchain-specific files (#1244)
* Move toolchain-specific options to their own files. * Clean up and modernize the use of toolchain options. * Use modern cmake LTO support. * Remove dead cmake code and cmake functions available in upstream cmake. * Update README.md to remove references to removed build options.
This commit is contained in:
parent
07e490254c
commit
aa59d94490
283
CMakeLists.txt
283
CMakeLists.txt
|
@ -1,11 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.19)
|
||||
|
||||
if(POLICY CMP0074)
|
||||
cmake_policy(SET CMP0074 NEW) # use Package_ROOT if set
|
||||
endif()
|
||||
if(POLICY CMP0077)
|
||||
cmake_policy(SET CMP0077 NEW) # use vars for options
|
||||
endif()
|
||||
cmake_policy(VERSION 3.19...3.28.3)
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
|
||||
|
||||
|
@ -53,6 +47,9 @@ if(NOT CMAKE_CXX_COMPILER_LAUNCHER)
|
|||
endif()
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_C_STANDARD_REQUIRED True)
|
||||
|
||||
project(VBA-M C CXX)
|
||||
|
||||
|
@ -145,8 +142,7 @@ if(MINGW)
|
|||
include_directories("${CMAKE_SOURCE_DIR}/dependencies/mingw-xaudio/include")
|
||||
endif()
|
||||
|
||||
find_package(Git)
|
||||
if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||
include(GitTagVersion)
|
||||
git_version(VERSION REVISION VERSION_RELEASE)
|
||||
|
||||
|
@ -449,270 +445,7 @@ if(ENABLE_NLS)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
include(ProcessorCount)
|
||||
ProcessorCount(num_cpus)
|
||||
|
||||
# Compiler stuff
|
||||
include(SetCompilerLinkerFlags)
|
||||
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL Clang AND CMAKE_CXX_COMPILER_ID STREQUAL Clang AND NOT MSVC)
|
||||
# TODO: This should also be done for clang-cl.
|
||||
include(LLVMToolchain)
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang AND NOT MSVC)
|
||||
unset(LTO_FLAGS)
|
||||
if(ENABLE_LTO)
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(num_cpus GREATER 1)
|
||||
set(LTO_FLAGS -flto=${num_cpus} -ffat-lto-objects)
|
||||
else()
|
||||
set(LTO_FLAGS -flto -ffat-lto-objects)
|
||||
endif()
|
||||
else()
|
||||
set(LTO_FLAGS -flto)
|
||||
endif()
|
||||
|
||||
# check that LTO is not broken before enabling it
|
||||
set(ORIG_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${LTO_FLAGS}")
|
||||
|
||||
include(CheckCXXSourceCompiles)
|
||||
check_cxx_source_compiles("int main(int argc, char** argv) { return 0; }" LTO_WORKS)
|
||||
|
||||
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
|
||||
|
||||
if(NOT LTO_WORKS)
|
||||
message(WARNING "LTO does not seem to be working on your system, if using clang make sure LLVMGold is installed")
|
||||
unset(LTO_FLAGS)
|
||||
set(ENABLE_LTO OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
unset(MY_C_OPT_FLAGS)
|
||||
|
||||
if(X86_32 OR X86_64)
|
||||
set(MY_C_OPT_FLAGS -mfpmath=sse -msse2)
|
||||
endif()
|
||||
|
||||
# common optimization flags
|
||||
if(NOT (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL Clang AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.3))
|
||||
set(MY_C_OPT_FLAGS ${MY_C_OPT_FLAGS} -Ofast -fomit-frame-pointer ${LTO_FLAGS})
|
||||
else()
|
||||
# LTO and -fomit-frame-pointer generate broken binaries on Lion with XCode 4.2 tools
|
||||
set(MY_C_OPT_FLAGS ${MY_C_OPT_FLAGS} -Ofast)
|
||||
endif()
|
||||
|
||||
# Common flags.
|
||||
set(MY_C_FLAGS -pipe -Wformat -Wformat-security)
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
# Require and optimize for Core2 level support, tune for generic.
|
||||
if(X86_64)
|
||||
set(MY_C_FLAGS ${MY_C_FLAGS} -march=core2 -mtune=generic)
|
||||
# Optimize for pentium-mmx and tune for generic for older XP builds.
|
||||
elseif(X86_32)
|
||||
set(MY_C_FLAGS ${MY_C_FLAGS} -march=pentium-mmx -mtune=generic)
|
||||
endif()
|
||||
|
||||
# Check for -fopenmp=libomp on clang.
|
||||
# if(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
|
||||
# check_cxx_compiler_flag("-fopenmp=libomp" FOPENMP_LIBOMP_FLAG)
|
||||
# if(FOPENMP_LIBOMP_FLAG)
|
||||
# set(MY_C_FLAGS ${MY_C_FLAGS} -fopenmp=libomp)
|
||||
# endif()
|
||||
# endif()
|
||||
|
||||
# common debug flags
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(MY_C_DBG_FLAGS -ggdb3 -Og -fno-omit-frame-pointer)
|
||||
else()
|
||||
set(MY_C_DBG_FLAGS -g -fno-omit-frame-pointer)
|
||||
endif()
|
||||
|
||||
if(ENABLE_ASAN)
|
||||
if(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
message(FATAL_ERROR "asan requires a debug build, set -DCMAKE_BUILD_TYPE=Debug")
|
||||
endif()
|
||||
|
||||
string(TOLOWER ${ENABLE_ASAN} SANITIZER)
|
||||
if(SANITIZER STREQUAL "on" OR SANITIZER STREQUAL "true")
|
||||
set(SANITIZER address)
|
||||
endif()
|
||||
list(PREPEND CMAKE_REQUIRED_LIBRARIES -fsanitize=${SANITIZER})
|
||||
check_cxx_compiler_flag("-fsanitize=${SANITIZER}" ASAN_SUPPORT_FLAG)
|
||||
if(${ASAN_SUPPORT_FLAG})
|
||||
list(PREPEND MY_C_DBG_FLAGS -fsanitize=${SANITIZER})
|
||||
else()
|
||||
message(FATAL_ERROR "asan not available to compiler.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ENABLE_SSP AND CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
if(WIN32)
|
||||
set(SSP_STATIC ON)
|
||||
endif()
|
||||
|
||||
find_package(SSP)
|
||||
|
||||
if(SSP_LIBRARY)
|
||||
list(APPEND MY_C_FLAGS -D_FORTIFY_SOURCE=2)
|
||||
list(APPEND MY_C_LINKER_FLAGS ${SSP_LIBRARY})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT (WIN32 OR X86_32)) # inline asm is not allowed with -fPIC
|
||||
set(MY_C_FLAGS ${MY_C_FLAGS} -fPIC)
|
||||
endif()
|
||||
|
||||
# check if ssp flags are supported for this version of gcc
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(ENABLE_SSP)
|
||||
check_cxx_compiler_flag(-fstack-protector-strong F_STACK_PROTECTOR_STRONG_FLAG)
|
||||
|
||||
if(F_STACK_PROTECTOR_STRONG_FLAG)
|
||||
set(MY_C_FLAGS ${MY_C_FLAGS} -fstack-protector-strong)
|
||||
|
||||
check_cxx_compiler_flag("--param ssp-buffer-size=4" SSP_BUFFER_SIZE_FLAG)
|
||||
|
||||
if(SSP_BUFFER_SIZE_FLAG)
|
||||
# we do not add it to MY_C_FLAGS because this breaks things like CMAKE_REQUIRED_LIBRARIES
|
||||
# which misinterpret compiler flags without leading dashes
|
||||
add_compile_options(--param ssp-buffer-size=4)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(MY_C_FLAGS ${MY_C_FLAGS} -fopenmp)
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
|
||||
unset(COMPILER_COLOR_DIAGNOSTICS)
|
||||
check_cxx_compiler_flag(-fdiagnostics-color=always COMPILER_COLOR_DIAGNOSTICS)
|
||||
if(COMPILER_COLOR_DIAGNOSTICS)
|
||||
add_compile_options(-fdiagnostics-color=always)
|
||||
else()
|
||||
unset(COMPILER_COLOR_DIAGNOSTICS)
|
||||
check_cxx_compiler_flag(-fdiagnostics-color COMPILER_COLOR_DIAGNOSTICS)
|
||||
if(COMPILER_COLOR_DIAGNOSTICS)
|
||||
add_compile_options(-fdiagnostics-color)
|
||||
endif()
|
||||
endif()
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
|
||||
unset(COMPILER_COLOR_DIAGNOSTICS)
|
||||
check_cxx_compiler_flag(-fcolor-diagnostics COMPILER_COLOR_DIAGNOSTICS)
|
||||
if(COMPILER_COLOR_DIAGNOSTICS)
|
||||
add_compile_options(-fcolor-diagnostics)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(MINGW AND NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
set(MY_C_FLAGS ${MY_C_FLAGS} -static-libgcc -static-libstdc++)
|
||||
endif()
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
set(MY_C_FLAGS ${MY_C_FLAGS} ${MY_C_DBG_FLAGS} -Wall -Wextra)
|
||||
else()
|
||||
set(MY_C_FLAGS ${MY_C_FLAGS} ${MY_C_OPT_FLAGS} -Wno-error)
|
||||
endif()
|
||||
|
||||
# for some reason this is necessary
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
|
||||
set(MY_C_FLAGS -I/usr/local/include ${MY_C_FLAGS})
|
||||
endif()
|
||||
|
||||
foreach(C_COMPILE_FLAG ${MY_C_FLAGS})
|
||||
add_compile_options(${C_COMPILE_FLAG})
|
||||
endforeach()
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
check_cxx_compiler_flag(-std=gnu++17 GNUPP17_FLAG)
|
||||
|
||||
if(NOT GNUPP17_FLAG)
|
||||
message(FATAL_ERROR "Your compiler does not support -std=gnu++17.")
|
||||
endif()
|
||||
|
||||
set(MY_CXX_FLAGS -std=gnu++17 -fexceptions)
|
||||
|
||||
foreach(ARG ${MY_CXX_FLAGS})
|
||||
set(MY_CXX_FLAGS_STR "${MY_CXX_FLAGS_STR} ${ARG}")
|
||||
endforeach()
|
||||
|
||||
# These must be set for C++ only, and we can't use generator expressions in
|
||||
# ADD_COMPILE_OPTIONS because that's a cmake 3.3 feature and we need 2.8.12
|
||||
# compat for Ubuntu 14.
|
||||
string(REGEX REPLACE "<FLAGS>" "<FLAGS> ${MY_CXX_FLAGS_STR} " CMAKE_CXX_COMPILE_OBJECT ${CMAKE_CXX_COMPILE_OBJECT})
|
||||
|
||||
foreach(ARG ${MY_C_FLAGS})
|
||||
set(MY_C_FLAGS_STR "${MY_C_FLAGS_STR} ${ARG}")
|
||||
endforeach()
|
||||
|
||||
# need all flags for linking, because of -flto etc.
|
||||
set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} ${MY_C_FLAGS_STR}")
|
||||
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} ${MY_C_FLAGS_STR}")
|
||||
|
||||
# for the gcc -fstack-protector* flags we need libssp
|
||||
# we also have to use the gcc- binutils for LTO to work
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(ENABLE_LTO)
|
||||
include(UseGCCBinUtilsWrappers)
|
||||
endif()
|
||||
|
||||
set(MY_C_LINKER_FLAGS ${MY_C_LINKER_FLAGS} -Wl,-allow-multiple-definition)
|
||||
|
||||
if(CMAKE_PREFIX_PATH)
|
||||
list(GET CMAKE_PREFIX_PATH 0 prefix_path_first)
|
||||
set(MY_C_LINKER_FLAGS ${MY_C_LINKER_FLAGS} "-Wl,-rpath-link=${prefix_path_first}/lib")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# set linker flags
|
||||
foreach(ARG ${MY_C_LINKER_FLAGS})
|
||||
set(MY_C_LINKER_FLAGS_STR "${MY_C_LINKER_FLAGS_STR} ${ARG}")
|
||||
endforeach()
|
||||
|
||||
set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} ${MY_C_LINKER_FLAGS_STR}")
|
||||
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} ${MY_C_LINKER_FLAGS_STR}")
|
||||
elseif(MSVC)
|
||||
# first remove all warnings flags, otherwise there is a warning about overriding them
|
||||
string(REGEX REPLACE "/[Ww][^ ]+" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
|
||||
string(REGEX REPLACE "/[Ww][^ ]+" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
|
||||
add_compiler_flags(/std:c++17 -D__STDC_LIMIT_MACROS /fp:fast /Oi)
|
||||
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:DEBUG>:Debug>" CACHE INTERNAL "")
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
add_compiler_flags(/ZI /W4 /Ob0 /Od /RTC1 /DDEBUG /EHsc)
|
||||
else()
|
||||
# Enable severe warnings for release builds, but suppress macro
|
||||
# redefinition warnings.
|
||||
add_compiler_flags(/W1 /wd4005 /DNDEBUG /EHsc)
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Release)
|
||||
add_compiler_flags(/O2 /Ob3)
|
||||
elseif(CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo)
|
||||
add_compiler_flags(/Zi /Ob1)
|
||||
elseif(CMAKE_BUILD_TYPE STREQUAL MinSizeRel)
|
||||
add_compiler_flags(/O1 /Ob1)
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown CMAKE_BUILD_TYPE: '${CMAKE_BUILD_TYPE}'")
|
||||
endif()
|
||||
|
||||
if(ENABLE_LTO)
|
||||
add_compiler_flags(/GL)
|
||||
add_linker_flags(/LTCG)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Assembler flags
|
||||
|
||||
if(ASM_ENABLED)
|
||||
string(REGEX REPLACE "<FLAGS>" "-I${CMAKE_SOURCE_DIR}/src/filters/hq/asm/ -O1 -w-orphan-labels" CMAKE_ASM_NASM_COMPILE_OBJECT ${CMAKE_ASM_NASM_COMPILE_OBJECT})
|
||||
endif()
|
||||
include(Toolchain)
|
||||
|
||||
if(APPLE)
|
||||
add_definitions(-DMACHO)
|
||||
|
@ -739,7 +472,7 @@ set(
|
|||
)
|
||||
|
||||
if(MSVC)
|
||||
set(SRC_MAIN ${SRC_MAIN} "dependencies/msvc/getopt.c")
|
||||
set(SRC_MAIN ${SRC_MAIN} "dependencies/msvc/getopt.c")
|
||||
endif()
|
||||
|
||||
set(
|
||||
|
@ -757,7 +490,7 @@ set(
|
|||
)
|
||||
|
||||
if(MSVC)
|
||||
set(HDR_MAIN ${HDR_MAIN} "dependencies/msvc/getopt.h")
|
||||
set(HDR_MAIN ${HDR_MAIN} "dependencies/msvc/getopt.h")
|
||||
endif()
|
||||
|
||||
if(ENABLE_FFMPEG)
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
- [Building a Libretro core](#building-a-libretro-core)
|
||||
- [Visual Studio Support](#visual-studio-support)
|
||||
- [Visual Studio Code Support](#visual-studio-code-support)
|
||||
- [Optional: clangd](#optional-clangd)
|
||||
- [Dependencies](#dependencies)
|
||||
- [Cross compiling for 32 bit on a 64 bit host](#cross-compiling-for-32-bit-on-a-64-bit-host)
|
||||
- [Cross Compiling for Win32](#cross-compiling-for-win32)
|
||||
|
@ -220,7 +219,6 @@ Here is the complete list:
|
|||
| ENABLE_DIRECT3D | Direct3D rendering for wxWidgets (Windows, **NOT IMPLEMENTED!!!**) | ON |
|
||||
| ENABLE_XAUDIO2 | Enable xaudio2 sound output for wxWidgets (Windows only) | ON |
|
||||
| ENABLE_OPENAL | Enable OpenAL for the wxWidgets port | AUTO |
|
||||
| ENABLE_SSP | Enable gcc stack protector support (gcc only) | OFF |
|
||||
| ENABLE_ASAN | Enable libasan sanitizers (by default address, only in debug mode) | OFF |
|
||||
| UPSTREAM_RELEASE | Do some release tasks, like codesigning, making zip and gpg sigs. | OFF |
|
||||
| BUILD_TESTING | Build the tests and enable ctest support. | ON |
|
||||
|
@ -228,9 +226,7 @@ Here is the complete list:
|
|||
| SDL2_STATIC | Try to link static SDL2 libraries | OFF |
|
||||
| SFML_STATIC_LIBRARIES | Try to link static SFML libraries | OFF |
|
||||
| FFMPEG_STATIC | Try to link static ffmpeg libraries | OFF |
|
||||
| SSP_STATIC | Try to link static gcc stack protector library (gcc only) | OFF except Win32 |
|
||||
| OPENAL_STATIC | Try to link static OpenAL libraries | OFF |
|
||||
| SSP_STATIC | Link gcc stack protecter libssp statically (gcc, with ENABLE_SSP) | OFF |
|
||||
| TRANSLATIONS_ONLY | Build only the translations.zip and nothing else | OFF |
|
||||
|
||||
Note for distro packagers, we use the CMake module
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
|
||||
#=============================================================================
|
||||
# Copyright 2010 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
# support for the nasm assembler
|
||||
|
||||
set(CMAKE_ASM_NASM_SOURCE_FILE_EXTENSIONS nasm asm)
|
||||
|
||||
if(NOT CMAKE_ASM_NASM_OBJECT_FORMAT)
|
||||
if(WIN32)
|
||||
if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
|
||||
SET(CMAKE_ASM_NASM_OBJECT_FORMAT win64)
|
||||
else()
|
||||
SET(CMAKE_ASM_NASM_OBJECT_FORMAT win32)
|
||||
endif()
|
||||
elseif(APPLE)
|
||||
EXECUTE_PROCESS(COMMAND ${CMAKE_ASM_NASM_COMPILER} -v COMMAND awk "{print \$3}" OUTPUT_VARIABLE NASM_VERSION)
|
||||
IF(NASM_VERSION VERSION_LESS 2.0)
|
||||
IF(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
|
||||
MESSAGE(FATAL_ERROR "Your nasm is too old to support AMD64, please install nasm from Homebrew or MacPorts.")
|
||||
ENDIF()
|
||||
SET(CMAKE_ASM_NAMS_OBJECT_FORMAT macho)
|
||||
ELSE()
|
||||
if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
|
||||
SET(CMAKE_ASM_NASM_OBJECT_FORMAT macho64)
|
||||
else()
|
||||
SET(CMAKE_ASM_NASM_OBJECT_FORMAT macho32)
|
||||
endif()
|
||||
ENDIF()
|
||||
else()
|
||||
if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
|
||||
SET(CMAKE_ASM_NASM_OBJECT_FORMAT elf64)
|
||||
else()
|
||||
SET(CMAKE_ASM_NASM_OBJECT_FORMAT elf32)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> <DEFINES> <FLAGS> -f ${CMAKE_ASM_NASM_OBJECT_FORMAT} -o <OBJECT> <SOURCE>")
|
||||
|
||||
# Load the generic ASMInformation file:
|
||||
set(ASM_DIALECT "_NASM")
|
||||
include(CMakeASMInformation)
|
||||
set(ASM_DIALECT)
|
|
@ -1,27 +0,0 @@
|
|||
|
||||
#=============================================================================
|
||||
# Copyright 2010 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
# Find the nasm assembler. yasm (http://www.tortall.net/projects/yasm/) is nasm compatible
|
||||
|
||||
SET(CMAKE_ASM_NASM_COMPILER_INIT nasm yasm)
|
||||
|
||||
IF(NOT CMAKE_ASM_NASM_COMPILER)
|
||||
FIND_PROGRAM(CMAKE_ASM_NASM_COMPILER nasm
|
||||
"$ENV{ProgramFiles}/NASM")
|
||||
ENDIF(NOT CMAKE_ASM_NASM_COMPILER)
|
||||
|
||||
# Load the generic DetermineASM compiler file with the DIALECT set properly:
|
||||
SET(ASM_DIALECT "_NASM")
|
||||
INCLUDE(CMakeDetermineASMCompiler)
|
||||
SET(ASM_DIALECT)
|
|
@ -1,23 +0,0 @@
|
|||
|
||||
#=============================================================================
|
||||
# Copyright 2010 Kitware, Inc.
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
# This file is used by EnableLanguage in cmGlobalGenerator to
|
||||
# determine that the selected ASM_NASM "compiler" works.
|
||||
# For assembler this can only check whether the compiler has been found,
|
||||
# because otherwise there would have to be a separate assembler source file
|
||||
# for each assembler on every architecture.
|
||||
|
||||
SET(ASM_DIALECT "_NASM")
|
||||
INCLUDE(CMakeTestASMCompiler)
|
||||
SET(ASM_DIALECT)
|
|
@ -1,76 +0,0 @@
|
|||
# FindSSP.cmake
|
||||
#
|
||||
# Find libssp necessary when using gcc with e.g. -fstack-protector=strong
|
||||
#
|
||||
# See: http://wiki.osdev.org/Stack_Smashing_Protector
|
||||
#
|
||||
# To use:
|
||||
#
|
||||
# put a copy into your <project_root>/cmake/
|
||||
#
|
||||
# In your main CMakeLists.txt do something like this:
|
||||
#
|
||||
# if(WIN32)
|
||||
# set(SSP_STATIC ON)
|
||||
# endif()
|
||||
#
|
||||
# find_package(SSP)
|
||||
#
|
||||
# if(SSP_LIBRARY)
|
||||
# set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} ${SSP_LIBRARY}")
|
||||
# set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} ${SSP_LIBRARY}")
|
||||
# endif()
|
||||
|
||||
# only do this when compiling with gcc/g++
|
||||
if(NOT CMAKE_COMPILER_IS_GNUCXX)
|
||||
return()
|
||||
endif()
|
||||
|
||||
function(FindSSP)
|
||||
if(NOT CMAKE_CXX_COMPILER AND CMAKE_C_COMPILER)
|
||||
set(CMAKE_CXX_COMPILER ${CMAKE_C_COMPILER})
|
||||
endif()
|
||||
|
||||
foreach(arg ${CMAKE_CXX_COMPILER_ARG1} ${CMAKE_CXX_COMPILER_ARG2} ${CMAKE_CXX_COMPILER_ARG3} ${CMAKE_CXX_COMPILER_ARG4} ${CMAKE_CXX_COMPILER_ARG5} ${CMAKE_CXX_COMPILER_ARG6} ${CMAKE_CXX_COMPILER_ARG7} ${CMAKE_CXX_COMPILER_ARG8} ${CMAKE_CXX_COMPILER_ARG9})
|
||||
string(STRIP ${arg} arg)
|
||||
set(gcc_args "${gcc_args};${arg}")
|
||||
endforeach()
|
||||
|
||||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${gcc_args} --print-prog-name=gcc OUTPUT_VARIABLE GCC_EXECUTABLE OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
if(WIN32 AND NOT MSYS)
|
||||
execute_process(COMMAND where.exe ${GCC_EXECUTABLE} OUTPUT_VARIABLE GCC_EXECUTABLE OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
else()
|
||||
execute_process(COMMAND sh -c "command -v ${GCC_EXECUTABLE}" OUTPUT_VARIABLE GCC_EXECUTABLE OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
endif()
|
||||
|
||||
get_filename_component(GCC_DIRNAME "${GCC_EXECUTABLE}" DIRECTORY)
|
||||
|
||||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${gcc_args} --print-libgcc-file-name OUTPUT_VARIABLE LIBGCC_FILE OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
get_filename_component(LIBGCC_DIRNAME "${LIBGCC_FILE}" DIRECTORY)
|
||||
|
||||
set(SSP_SEARCH_PATHS ${GCC_DIRNAME} ${LIBGCC_DIRNAME})
|
||||
|
||||
if(SSP_STATIC)
|
||||
if(WIN32)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a)
|
||||
else()
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_library(SSP_LIBRARY
|
||||
NAMES ssp libssp
|
||||
HINTS ${SSP_SEARCH_PATHS}
|
||||
PATH_SUFFIXES lib64 lib lib/x64 lib/x86
|
||||
)
|
||||
|
||||
set(SSP_LIBRARY PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
FindSSP()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(SSP REQUIRED_VARS SSP_LIBRARY)
|
|
@ -7,23 +7,6 @@
|
|||
#
|
||||
# Returns the refspec and sha hash of the current head revision
|
||||
#
|
||||
# git_describe(<var> [<additional arguments to git describe> ...])
|
||||
#
|
||||
# Returns the results of git describe on the source tree, and adjusting
|
||||
# the output so that it tests false if an error occurs.
|
||||
#
|
||||
# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
|
||||
#
|
||||
# Returns the results of git describe --exact-match on the source tree,
|
||||
# and adjusting the output so that it tests false if there was no exact
|
||||
# matching tag.
|
||||
#
|
||||
# git_local_changes(<var>)
|
||||
#
|
||||
# Returns either "CLEAN" or "DIRTY" with respect to uncommitted changes.
|
||||
# Uses the return code of "git diff-index --quiet HEAD --".
|
||||
# Does not regard untracked files.
|
||||
#
|
||||
# Requires CMake 2.6 or newer (uses the 'function' command)
|
||||
#
|
||||
# Original Author:
|
||||
|
@ -85,84 +68,3 @@ function(get_git_head_revision _refspecvar _hashvar)
|
|||
set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE)
|
||||
set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_describe _var)
|
||||
if(NOT GIT_FOUND)
|
||||
find_package(Git QUIET)
|
||||
endif()
|
||||
get_git_head_revision(refspec hash)
|
||||
if(NOT GIT_FOUND)
|
||||
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
if(NOT hash)
|
||||
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# TODO sanitize
|
||||
#if((${ARGN}" MATCHES "&&") OR
|
||||
# (ARGN MATCHES "||") OR
|
||||
# (ARGN MATCHES "\\;"))
|
||||
# message("Please report the following error to the project!")
|
||||
# message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
|
||||
#endif()
|
||||
|
||||
#message(STATUS "Arguments to execute_process: ${ARGN}")
|
||||
|
||||
execute_process(COMMAND
|
||||
"${GIT_EXECUTABLE}"
|
||||
describe
|
||||
${hash}
|
||||
${ARGN}
|
||||
WORKING_DIRECTORY
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
RESULT_VARIABLE
|
||||
res
|
||||
OUTPUT_VARIABLE
|
||||
out
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT res EQUAL 0)
|
||||
set(out "${out}-${res}-NOTFOUND")
|
||||
endif()
|
||||
|
||||
set(${_var} "${out}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_get_exact_tag _var)
|
||||
git_describe(out --exact-match ${ARGN})
|
||||
set(${_var} "${out}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_local_changes _var)
|
||||
if(NOT GIT_FOUND)
|
||||
find_package(Git QUIET)
|
||||
endif()
|
||||
get_git_head_revision(refspec hash)
|
||||
if(NOT GIT_FOUND)
|
||||
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
if(NOT hash)
|
||||
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND
|
||||
"${GIT_EXECUTABLE}"
|
||||
diff-index --quiet HEAD --
|
||||
WORKING_DIRECTORY
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
RESULT_VARIABLE
|
||||
res
|
||||
OUTPUT_VARIABLE
|
||||
out
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(res EQUAL 0)
|
||||
set(${_var} "CLEAN" PARENT_SCOPE)
|
||||
else()
|
||||
set(${_var} "DIRTY" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
|
|
@ -3,7 +3,6 @@ function(git_version version revision version_release)
|
|||
set(${revision} "" CACHE STRING "Latest Git Tag Revision" FORCE)
|
||||
set(${version_release} 0 CACHE STRING "Is this a versioned release without revision" FORCE)
|
||||
|
||||
find_package(Git)
|
||||
if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||
# get latest version from tag history
|
||||
execute_process(COMMAND "${GIT_EXECUTABLE}" tag "--format=%(align:width=20)%(refname:short)%(end)%(if)%(*objectname)%(then)%(*objectname)%(else)%(objectname)%(end)" --sort=-v:refname OUTPUT_VARIABLE tags OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
function(use_llvm_toolchain)
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL Clang)
|
||||
set(compiler "${CMAKE_C_COMPILER}")
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
|
||||
set(compiler "${CMAKE_CXX_COMPILER}")
|
||||
else()
|
||||
return()
|
||||
endif()
|
||||
|
||||
foreach(tool ar ranlib ld nm objdump as)
|
||||
execute_process(
|
||||
COMMAND "${compiler}" -print-prog-name=llvm-${tool}
|
||||
OUTPUT_VARIABLE prog_path
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
# for FreeBSD
|
||||
if(NOT prog_path MATCHES "^/")
|
||||
get_filename_component(
|
||||
abs_path ${prog_path} ABSOLUTE
|
||||
BASE_DIR /usr/local/llvm-devel/bin
|
||||
)
|
||||
|
||||
if(EXISTS ${abs_path})
|
||||
set(prog_path ${abs_path})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(prog_path MATCHES "^/")
|
||||
if(tool STREQUAL ld)
|
||||
set(tool linker)
|
||||
elseif(tool STREQUAL as)
|
||||
set(tool asm_compiler)
|
||||
endif()
|
||||
|
||||
string(TOUPPER ${tool} utool)
|
||||
|
||||
set(CMAKE_${utool} "${prog_path}" PARENT_SCOPE)
|
||||
set(CMAKE_${utool} "${prog_path}" CACHE FILEPATH "${tool}" FORCE)
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
use_llvm_toolchain()
|
|
@ -10,8 +10,6 @@ if(NOT EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
|||
message(FATAL_ERROR "releases can only be done from a git clone")
|
||||
endif()
|
||||
|
||||
find_package(Git)
|
||||
|
||||
if(NOT GIT_FOUND)
|
||||
message(FATAL_ERROR "git is required to make a release")
|
||||
endif()
|
||||
|
|
|
@ -6,8 +6,6 @@ option(ENABLE_WX "Build the wxWidgets port" ON)
|
|||
option(ENABLE_DEBUGGER "Enable the debugger" ON)
|
||||
option(ENABLE_ASAN "Enable -fsanitize=<option>, address by default, requires debug build" OFF)
|
||||
|
||||
option(ENABLE_SSP "Enable gcc stack protector support" OFF)
|
||||
|
||||
# Static linking
|
||||
set(VBAM_STATIC_DEFAULT OFF)
|
||||
if(VCPKG_TARGET_TRIPLET MATCHES -static OR CMAKE_TOOLCHAIN_FILE MATCHES "mxe|-static")
|
||||
|
@ -22,7 +20,6 @@ if(VBAM_STATIC)
|
|||
set(SDL2_STATIC ON)
|
||||
set(SFML_STATIC_LIBRARIES ON)
|
||||
set(FFMPEG_STATIC ON)
|
||||
set(SSP_STATIC ON)
|
||||
set(OPENAL_STATIC ON)
|
||||
set_property(GLOBAL PROPERTY LINK_SEARCH_START_STATIC ON)
|
||||
set_property(GLOBAL PROPERTY LINK_SEARCH_END_STATIC ON)
|
||||
|
@ -101,16 +98,13 @@ endif()
|
|||
option(ENABLE_ONLINEUPDATES "Enable online update checks" ${ONLINEUPDATES_DEFAULT})
|
||||
option(HTTPS "Use https URL for winsparkle" ON)
|
||||
|
||||
set(LTO_DEFAULT ON)
|
||||
|
||||
# gcc lto produces buggy binaries for 64 bit mingw
|
||||
# and we generally don't want it when debugging because it makes linking slow
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Debug OR (WIN32 AND CMAKE_COMPILER_IS_GNUCXX))
|
||||
# We generally don't want LTO when debugging because it makes linking slow
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
set(LTO_DEFAULT OFF)
|
||||
else()
|
||||
set(LTO_DEFAULT ON)
|
||||
endif()
|
||||
|
||||
option(ENABLE_LTO "Compile with Link Time Optimization" ${LTO_DEFAULT})
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO})
|
||||
|
||||
option(ENABLE_GBA_LOGGING "Enable extended GBA logging" ON)
|
||||
|
||||
|
@ -129,7 +123,14 @@ option(TRANSLATIONS_ONLY "Build only the translations.zip" OFF)
|
|||
if(WIN32)
|
||||
# not yet implemented
|
||||
option(ENABLE_DIRECT3D "Enable Direct3D rendering for the wxWidgets port" OFF)
|
||||
option(ENABLE_XAUDIO2 "Enable xaudio2 sound output for the wxWidgets port" ON)
|
||||
|
||||
set(XAUDIO2_DEFAULT ON)
|
||||
if (MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL Clang)
|
||||
# TODO: We should update the XAudio headers to build with clang-cl. See
|
||||
# https://github.com/visualboyadvance-m/visualboyadvance-m/issues/1021
|
||||
set(XAUDIO2_DEFAULT OFF)
|
||||
endif()
|
||||
option(ENABLE_XAUDIO2 "Enable xaudio2 sound output for the wxWidgets port" ${XAUDIO2_DEFAULT})
|
||||
endif()
|
||||
|
||||
option(ENABLE_FAUDIO "Enable FAudio sound output for the wxWidgets port" OFF)
|
||||
|
|
|
@ -1,11 +1,3 @@
|
|||
if(POLICY CMP0012)
|
||||
cmake_policy(SET CMP0012 NEW) # Saner if() behavior.
|
||||
endif()
|
||||
|
||||
if(POLICY CMP0135)
|
||||
cmake_policy(SET CMP0135 NEW) # Use timestamps from archives.
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED VCPKG_TARGET_TRIPLET)
|
||||
if(NOT WIN32)
|
||||
return()
|
||||
|
@ -55,28 +47,6 @@ if(NOT DEFINED VCPKG_TARGET_TRIPLET)
|
|||
message(STATUS "Inferred VCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET}")
|
||||
endif()
|
||||
|
||||
function(vcpkg_seconds)
|
||||
if(CMAKE_HOST_SYSTEM MATCHES Windows OR ((NOT DEFINED CMAKE_HOST_SYSTEM) AND WIN32))
|
||||
execute_process(
|
||||
COMMAND cmd /c echo %TIME:~0,8%
|
||||
OUTPUT_VARIABLE time
|
||||
)
|
||||
else()
|
||||
execute_process(
|
||||
COMMAND date +%H:%M:%S
|
||||
OUTPUT_VARIABLE time
|
||||
)
|
||||
endif()
|
||||
|
||||
string(SUBSTRING "${time}" 0 2 hours)
|
||||
string(SUBSTRING "${time}" 3 2 minutes)
|
||||
string(SUBSTRING "${time}" 6 2 secs)
|
||||
|
||||
math(EXPR seconds "(${hours} * 60 * 60) + (${minutes} * 60) + ${secs}")
|
||||
|
||||
set(seconds ${seconds} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(vcpkg_check_git_status git_status)
|
||||
# The VS vcpkg component cannot be written to without elevation.
|
||||
if(NOT git_status EQUAL 0 AND NOT VCPKG_ROOT MATCHES "^C:/Program Files/Microsoft Visual Studio/")
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
include(VbamFunctions)
|
||||
|
||||
function(add_compiler_flags)
|
||||
foreach(var RELEASE DEBUG RELWITHDEBINFO MINSIZEREL)
|
||||
set("CMAKE_CXX_FLAGS_${var}" "" CACHE STRING "MUST BE UNSET" FORCE)
|
||||
set("CMAKE_CXX_FLAGS_${var}" "" PARENT_SCOPE)
|
||||
set("CMAKE_C_FLAGS_${var}" "" CACHE STRING "MUST BE UNSET" FORCE)
|
||||
set("CMAKE_C_FLAGS_${var}" "" PARENT_SCOPE)
|
||||
endforeach()
|
||||
|
||||
# Set C and CXX flags if not already set.
|
||||
foreach(flag ${ARGV})
|
||||
foreach(var CMAKE_CXX_FLAGS CMAKE_C_FLAGS)
|
||||
# Remove any duplicates first.
|
||||
remove_dupes("${${var}}" "${var}")
|
||||
|
||||
string(FIND "${${var}}" "${flag}" found)
|
||||
|
||||
if(found EQUAL -1)
|
||||
set("${var}" "${${var}} ${flag}" CACHE STRING "Compiler Flags" FORCE)
|
||||
set("${var}" "${${var}} ${flag}" PARENT_SCOPE)
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
function(add_linker_flags)
|
||||
# Set linker flags if not already set.
|
||||
foreach(flag ${ARGV})
|
||||
foreach(var EXE SHARED)
|
||||
set(var "CMAKE_${var}_LINKER_FLAGS")
|
||||
|
||||
# Remove any duplicates first.
|
||||
remove_dupes("${${var}}" "${var}")
|
||||
|
||||
string(FIND "${${var}}" "${flag}" found)
|
||||
|
||||
if(found EQUAL -1)
|
||||
set("${var}" "${${var}} ${flag}" CACHE STRING "Linker Flags" FORCE)
|
||||
set("${var}" "${${var}} ${flag}" PARENT_SCOPE)
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
endfunction()
|
|
@ -0,0 +1,73 @@
|
|||
include(CheckCXXCompilerFlag)
|
||||
|
||||
if(X86_32 OR X86_64)
|
||||
add_compile_options(-mfpmath=sse -msse2)
|
||||
endif()
|
||||
|
||||
if(X86_64)
|
||||
# Require and optimize for Core2 level support, tune for generic.
|
||||
add_compile_options(-march=core2 -mtune=generic)
|
||||
elseif(X86_32)
|
||||
# Optimize for pentium-mmx and tune for generic for older builds.
|
||||
add_compile_options(-march=pentium-mmx -mtune=generic)
|
||||
endif()
|
||||
|
||||
# Common flags.
|
||||
add_compile_options(
|
||||
-pipe
|
||||
-Wno-unused-command-line-argument
|
||||
-Wformat
|
||||
-Wformat-security
|
||||
-feliminate-unused-debug-types
|
||||
-fdiagnostics-color=always
|
||||
)
|
||||
|
||||
if(ENABLE_ASAN)
|
||||
if(NOT CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
message(WARNING "ASAN requires debug build, set -DCMAKE_BUILD_TYPE=Debug, disabling.")
|
||||
set(ENABLE_ASAN OFF)
|
||||
endif()
|
||||
|
||||
# It is necessary to modify the linker flagas for the compiler check to work.
|
||||
set(BACKUP_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-fsanitize=address")
|
||||
check_cxx_compiler_flag(-fsanitize=address ASAN_SUPPORTED)
|
||||
set(CMAKE_EXE_LINKER_FLAGS ${BACKUP_LINKER_FLAGS})
|
||||
|
||||
if(ASAN_SUPPORTED)
|
||||
add_compile_options(-fsanitize=address)
|
||||
add_link_options(-fsanitize=address)
|
||||
else()
|
||||
message(WARNING "ASAN not available for the compiler, disabling.")
|
||||
set(ENABLE_ASAN OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# check if ssp flags are supported.
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
check_cxx_compiler_flag(-fstack-protector-strong STACK_PROTECTOR_SUPPORTED)
|
||||
|
||||
if(STACK_PROTECTOR_SUPPORTED)
|
||||
add_compile_options(-fstack-protector-strong)
|
||||
|
||||
check_cxx_compiler_flag("--param ssp-buffer-size=4" SSP_BUFFER_SIZE_SUPPORTED)
|
||||
if(SSP_BUFFER_SIZE_SUPPORTED)
|
||||
add_compile_options(--param ssp-buffer-size=4)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT ENABLE_ASM) # inline asm is not allowed with -fPIC
|
||||
add_compile_options(-fPIC)
|
||||
endif()
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
add_compile_options(-ggdb3 -Og -fno-omit-frame-pointer -Wall -Wextra)
|
||||
else()
|
||||
add_compile_options(-Ofast -fomit-frame-pointer)
|
||||
endif()
|
||||
|
||||
# for some reason this is necessary
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
|
||||
include_directories(/usr/local/include)
|
||||
endif()
|
|
@ -0,0 +1,41 @@
|
|||
if(CMAKE_C_COMPILER_ID STREQUAL Clang)
|
||||
set(compiler "${CMAKE_C_COMPILER}")
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
|
||||
set(compiler "${CMAKE_CXX_COMPILER}")
|
||||
else()
|
||||
return()
|
||||
endif()
|
||||
|
||||
foreach(tool ar ranlib ld nm objdump as)
|
||||
execute_process(
|
||||
COMMAND "${compiler}" -print-prog-name=llvm-${tool}
|
||||
OUTPUT_VARIABLE prog_path
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
# for FreeBSD
|
||||
if(NOT prog_path MATCHES "^/")
|
||||
get_filename_component(
|
||||
abs_path ${prog_path} ABSOLUTE
|
||||
BASE_DIR /usr/local/llvm-devel/bin
|
||||
)
|
||||
|
||||
if(EXISTS ${abs_path})
|
||||
set(prog_path ${abs_path})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(prog_path MATCHES "^/")
|
||||
if(tool STREQUAL ld)
|
||||
set(tool linker)
|
||||
elseif(tool STREQUAL as)
|
||||
set(tool asm_compiler)
|
||||
endif()
|
||||
|
||||
string(TOUPPER ${tool} utool)
|
||||
|
||||
set(CMAKE_${utool} "${prog_path}" PARENT_SCOPE)
|
||||
set(CMAKE_${utool} "${prog_path}" CACHE FILEPATH "${tool}" FORCE)
|
||||
endif()
|
||||
endforeach()
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
# this has to run after the toolchain is initialized so it can't be in
|
||||
# Win32deps.cmake
|
||||
include_directories("${CMAKE_SOURCE_DIR}/dependencies/mingw-include")
|
||||
include_directories("${CMAKE_SOURCE_DIR}/dependencies/mingw-xaudio/include")
|
||||
|
||||
# Win32 deps submodule
|
||||
set(git_checkout FALSE)
|
||||
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||
set(git_checkout TRUE)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} submodule update --init --remote --recursive
|
||||
RESULT_VARIABLE git_status
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/dependencies/mingw-xaudio/include")
|
||||
if(NOT (git_checkout AND git_status EQUAL 0))
|
||||
message(FATAL_ERROR "Please pull in git submodules, e.g.\nrun: git submodule update --init --remote --recursive")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# hack for ninja in msys2
|
||||
if(WIN32 AND CMAKE_GENERATOR STREQUAL Ninja AND NOT "$ENV{MSYSTEM_PREFIX}" STREQUAL "")
|
||||
set(MSYS ON)
|
||||
endif()
|
||||
|
||||
if(MSYS AND CMAKE_CXX_COMPILER_ID STREQUAL Clang)
|
||||
if($ENV{MSYSTEM} STREQUAL CLANG64)
|
||||
cygpath(prefix "$ENV{MSYSTEM_PREFIX}/x86_64-w64-mingw32")
|
||||
list(APPEND CMAKE_PREFIX_PATH "${prefix}")
|
||||
elseif($ENV{MSYSTEM} STREQUAL CLANG32)
|
||||
cygpath(prefix "$ENV{MSYSTEM_PREFIX}/i686-w64-mingw32")
|
||||
list(APPEND CMAKE_PREFIX_PATH "${prefix}")
|
||||
endif()
|
||||
|
||||
set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}" CACHE INTERNAL "prefix search path for find_XXXX" FORCE)
|
||||
endif()
|
||||
|
||||
# link libgcc/libstdc++ statically on mingw
|
||||
# and adjust link command when making a static binary
|
||||
if(CMAKE_COMPILER_IS_GNUCXX AND VBAM_STATIC)
|
||||
# some dists don't have a static libpthread
|
||||
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread ")
|
||||
|
||||
if(WIN32)
|
||||
add_custom_command(
|
||||
TARGET visualboyadvance-m PRE_LINK
|
||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/msys-link-static.cmake
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
else()
|
||||
add_custom_command(
|
||||
TARGET visualboyadvance-m PRE_LINK
|
||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/link-static.cmake
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
endif()
|
||||
endif()
|
|
@ -0,0 +1,65 @@
|
|||
# Set the runtime library properly.
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:DEBUG>:Debug>" CACHE INTERNAL "")
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL MSVC)
|
||||
# MSVC-specific flags (not supported by clang-cl).
|
||||
add_compile_options(/nologo)
|
||||
if (NOT CMAKE_GENERATOR MATCHES "Ninja")
|
||||
# Multi-processor compilation does not work well with Ninja.
|
||||
add_compile_options(/MP)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include_directories("${CMAKE_SOURCE_DIR}/dependencies/msvc")
|
||||
|
||||
add_compile_definitions(
|
||||
_FORCENAMELESSUNION
|
||||
WIN32_LEAN_AND_MEAN
|
||||
WIN32
|
||||
_WINDOWS
|
||||
__STDC_LIMIT_MACROS
|
||||
__STDC_CONSTANT_MACROS
|
||||
_CRT_SECURE_NO_WARNINGS
|
||||
)
|
||||
add_compile_options(
|
||||
/W4
|
||||
/GR
|
||||
/EHsc
|
||||
)
|
||||
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
add_compile_definitions(_DEBUG DEBUG)
|
||||
add_compile_options(/Ob0 /Od /RTC1)
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL MSVC)
|
||||
# Use Edit and Continue with MSVC.
|
||||
add_compile_options(/ZI)
|
||||
else()
|
||||
add_compile_options(/Zi)
|
||||
endif()
|
||||
else()
|
||||
add_compile_definitions(NDEBUG)
|
||||
add_compile_options(/MT /Oi /Gy /Zi)
|
||||
add_link_options(/OPT:REF /OPT:ICF)
|
||||
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
|
||||
add_compile_options(/O1 /Ob1)
|
||||
elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
|
||||
add_compile_options(/O2 /Ob1)
|
||||
else()
|
||||
add_compile_options(/O2)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CMAKE_RC_FLAGS "-c65001 /DWIN32" CACHE STRING "" FORCE)
|
||||
|
||||
# We need to explicitly set all of these to override the CMake defaults.
|
||||
set(CMAKE_CXX_FLAGS "" CACHE STRING "" FORCE)
|
||||
set(CMAKE_C_FLAGS "" CACHE STRING "" FORCE)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "" CACHE STRING "" FORCE)
|
||||
set(CMAKE_C_FLAGS_DEBUG "" CACHE STRING "" FORCE)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "" CACHE STRING "" FORCE)
|
||||
set(CMAKE_C_FLAGS_RELEASE "" CACHE STRING "" FORCE)
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "" CACHE STRING "" FORCE)
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "" CACHE STRING "" FORCE)
|
||||
set(CMAKE_CXX_FLAGS_MINSIZEREL "" CACHE STRING "" FORCE)
|
||||
set(CMAKE_C_FLAGS_MINSIZEREL "" CACHE STRING "" FORCE)
|
|
@ -0,0 +1,35 @@
|
|||
# Compiler stuff
|
||||
include(ProcessorCount)
|
||||
ProcessorCount(num_cpus)
|
||||
|
||||
if (ENABLE_LTO)
|
||||
include(CheckIPOSupported)
|
||||
check_ipo_supported(RESULT LTO_SUPPORTED)
|
||||
if (LTO_SUPPORTED)
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||
else()
|
||||
message(WARNING "LTO is not supported by the compiler, diasabling LTO")
|
||||
set(ENABLE_LTO OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL Clang AND CMAKE_CXX_COMPILER_ID STREQUAL Clang AND NOT MSVC)
|
||||
# TODO: This should also be done for clang-cl.
|
||||
include(Toolchain-llvm)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
# This also includes clang-cl.
|
||||
include(Toolchain-msvc)
|
||||
elseif(MINGW)
|
||||
include(Toolchain-mingw)
|
||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL GNU OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
|
||||
include(Toolchain-gcc-clang)
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported compiler")
|
||||
endif()
|
||||
|
||||
# Assembler flags
|
||||
if(ASM_ENABLED)
|
||||
string(REGEX REPLACE "<FLAGS>" "-I${CMAKE_SOURCE_DIR}/src/filters/hq/asm/ -O1 -w-orphan-labels" CMAKE_ASM_NASM_COMPILE_OBJECT ${CMAKE_ASM_NASM_COMPILE_OBJECT})
|
||||
endif()
|
|
@ -2,12 +2,6 @@
|
|||
# Update version in appcast.xml to latest tag.
|
||||
# Commit web-data.
|
||||
|
||||
find_package(Git)
|
||||
|
||||
if(NOT GIT_FOUND)
|
||||
message(FATAL_ERROR "git is required to update the appcast")
|
||||
endif()
|
||||
|
||||
function(update_appcast)
|
||||
if(UPDATE_APPCAST STREQUAL UNDO)
|
||||
file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/web-data)
|
||||
|
|
|
@ -1,103 +0,0 @@
|
|||
# UseGCCBinUtilsWrappers.cmake
|
||||
#
|
||||
# Use gcc binutils wrappers such as gcc-ar, this may be necessary for LTO.
|
||||
#
|
||||
# To use:
|
||||
#
|
||||
# put a copy into your <project_root>/CMakeScripts/
|
||||
#
|
||||
# In your main CMakeLists.txt add the command:
|
||||
#
|
||||
# INCLUDE(UseGCCBinUtilsWrappers)
|
||||
#
|
||||
# BSD 2-Clause License
|
||||
#
|
||||
# Copyright (c) 2016, Rafael Kitover
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice, this
|
||||
# list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# only do this when compiling with gcc/g++
|
||||
IF(NOT (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUC))
|
||||
RETURN()
|
||||
ENDIF()
|
||||
|
||||
# first try appending -util to basename of compiler
|
||||
STRING(REGEX MATCH "\\.(exe|EXE)$" GCC_EXE_SUFFIX ${CMAKE_C_COMPILER})
|
||||
STRING(REGEX REPLACE "\\.(exe|EXE)$" "" GCC_BASENAME ${CMAKE_C_COMPILER})
|
||||
|
||||
SET(GCC_AR "${GCC_BASENAME}-ar${GCC_EXE_SUFFIX}")
|
||||
SET(GCC_NM "${GCC_BASENAME}-nm${GCC_EXE_SUFFIX}")
|
||||
SET(GCC_RANLIB "${GCC_BASENAME}-ranlib${GCC_EXE_SUFFIX}")
|
||||
|
||||
# if that does not work, try looking for gcc-util in the compiler directory,
|
||||
# and failing that in the PATH
|
||||
|
||||
GET_FILENAME_COMPONENT(GCC_DIRNAME ${CMAKE_C_COMPILER} DIRECTORY)
|
||||
|
||||
IF(NOT EXISTS ${GCC_AR})
|
||||
UNSET(GCC_AR)
|
||||
|
||||
FIND_PROGRAM(GCC_AR NAMES gcc-ar gcc-ar.exe GCC-AR.EXE HINTS ${GCC_DIRNAME})
|
||||
ENDIF()
|
||||
|
||||
IF(NOT EXISTS ${GCC_NM})
|
||||
UNSET(GCC_NM)
|
||||
|
||||
FIND_PROGRAM(GCC_NM NAMES gcc-nm gcc-nm.exe GCC-NM.EXE HINTS ${GCC_DIRNAME})
|
||||
ENDIF()
|
||||
|
||||
IF(NOT EXISTS ${GCC_RANLIB})
|
||||
UNSET(GCC_RANLIB)
|
||||
|
||||
FIND_PROGRAM(GCC_RANLIB NAMES gcc-ranlib gcc-ranlib.exe GCC-RANLIB.EXE HINTS ${GCC_DIRNAME})
|
||||
ENDIF()
|
||||
|
||||
INCLUDE(PathRun)
|
||||
|
||||
IF(EXISTS ${GCC_AR})
|
||||
MESSAGE("-- Found gcc-ar: ${GCC_AR}")
|
||||
|
||||
SET(target "${CMAKE_BINARY_DIR}/gcc-ar-wrap")
|
||||
MAKE_PATH_RUN_WRAPPER("${GCC_AR}" "${target}")
|
||||
SET(CMAKE_AR "${target}")
|
||||
ENDIF()
|
||||
|
||||
IF(EXISTS ${GCC_NM})
|
||||
MESSAGE("-- Found gcc-nm: ${GCC_NM}")
|
||||
|
||||
SET(target "${CMAKE_BINARY_DIR}/gcc-nm-wrap")
|
||||
MAKE_PATH_RUN_WRAPPER("${GCC_NM}" "${target}")
|
||||
SET(CMAKE_NM "${target}")
|
||||
ENDIF()
|
||||
|
||||
IF(EXISTS ${GCC_RANLIB})
|
||||
MESSAGE("-- Found gcc-ranlib: ${GCC_RANLIB}")
|
||||
|
||||
SET(target "${CMAKE_BINARY_DIR}/gcc-ranlib-wrap")
|
||||
MAKE_PATH_RUN_WRAPPER("${GCC_RANLIB}" "${target}")
|
||||
SET(CMAKE_RANLIB "${target}")
|
||||
ENDIF()
|
||||
|
||||
FOREACH(VAR "GCC_AR" "GCC_NM" "GCC_RANLIB" "GCC_DIRNAME" "GCC_BASENAME" "GCC_EXE_SUFFIX" "target")
|
||||
UNSET(${VAR})
|
||||
ENDFOREACH()
|
|
@ -1,23 +1,4 @@
|
|||
# Do not use this file directly. Always use the top level CMakeLists.txt file
|
||||
|
||||
if(COMMAND cmake_policy)
|
||||
cmake_policy(SET CMP0003 NEW) # link to full path of libs
|
||||
cmake_policy(SET CMP0005 NEW) # escapes in add_definitions
|
||||
|
||||
|
||||
if(POLICY CMP0074)
|
||||
cmake_policy(SET CMP0074 NEW) # use Package_ROOT if set
|
||||
endif()
|
||||
|
||||
if(POLICY CMP0077)
|
||||
cmake_policy(SET CMP0077 NEW) # use vars for options
|
||||
endif()
|
||||
|
||||
if(POLICY CMP0043)
|
||||
cmake_policy(SET CMP0043 NEW) # for wxWidgets, use generator expressions
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(VbamFunctions)
|
||||
|
||||
set(VBAM_LIBS ${VBAMCORE_LIBS})
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
// DirectSound8
|
||||
#define DIRECTSOUND_VERSION 0x0800
|
||||
#include <mmeapi.h>
|
||||
#include <uuids.h>
|
||||
#include <dsound.h>
|
||||
|
||||
extern bool soundBufferLow;
|
||||
|
|
Loading…
Reference in New Issue