diff --git a/CMakeLists.txt b/CMakeLists.txt index 50ca88922..abfe1b7f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,13 +24,50 @@ project(86Box HOMEPAGE_URL "https://86box.net" LANGUAGES C CXX) -if(WIN32 AND VCPKG_TOOLCHAIN) - if(VCPKG_TARGET_TRIPLET MATCHES "-windows-static$") - # `-static` triplet, use the statically linked CRT - set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +include(CPack) +include(CMakeDependentOption) + +# Basic build options +if(WIN32) + if(VCPKG_TOOLCHAIN) + # For vcpkg builds we have to respect the linking method used by the + # specified triplet. + set(NO_STATIC_OPTION ON) + if(VCPKG_TARGET_TRIPLET MATCHES "-windows-static$") + # `-static` triplet, use static linking + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + set(STATIC_BUILD ON) + elseif(VCPKG_TARGET_TRIPLET MATCHES "-windows-static-md$") + # `-static-md` triplet, use static linking with dynamic CRT + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") + set(STATIC_BUILD ON) + elseif() + # Regular triplet, use dynamic linking + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") + set(STATIC_BUILD OFF) + endif() + endif() + + # Prefer static builds on Windows + set(PREFER_STATIC ON) + + # Default value for the `WIN32` target property, which specifies whether + # to build the application for the Windows GUI or console subsystem + option(CMAKE_WIN32_EXECUTABLE "Build a Windows GUI executable" ON) +else() + # Prefer dynamic builds everywhere else + set(PREFER_STATIC OFF) +endif() + +if(APPLE) + option(CMAKE_MACOSX_BUNDLE "Build a macOS bundle (.app)" ON) +endif() + +if(NOT NO_STATIC_OPTION) + if(PREFER_STATIC) + option(STATIC_BUILD "Static build" ON) else() - # Regular triplet (or `-static-md`), use the dynamically linked CRT - set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") + option(STATIC_BUILD "Static build" OFF) endif() endif() @@ -42,10 +79,6 @@ if (NOT ARCH) set(ARCH unknown) endif() -include(CPack) - -include(CMakeDependentOption) - add_compile_definitions(CMAKE) add_compile_definitions("$<$:DEBUG>") diff --git a/cmake/flags-gcc-aarch64.cmake b/cmake/flags-gcc-aarch64.cmake index 5e37b9c3f..146a869fc 100644 --- a/cmake/flags-gcc-aarch64.cmake +++ b/cmake/flags-gcc-aarch64.cmake @@ -14,7 +14,7 @@ # Copyright 2021 David Hrdlička. # -include(${CMAKE_CURRENT_LIST_DIR}/flags-gcc.cmake) +string(APPEND CMAKE_C_FLAGS_INIT " -march=armv8-a -mfloat-abi=hard") +string(APPEND CMAKE_CXX_FLAGS_INIT " -march=armv8-a -mfloat-abi=hard") -set(CMAKE_C_FLAGS_INIT "-march=armv8-a -mfloat-abi=hard ${CMAKE_C_FLAGS_INIT}") -set(CMAKE_CXX_FLAGS_INIT "-march=armv8-a -mfloat-abi=hard ${CMAKE_CXX_FLAGS_INIT}") \ No newline at end of file +include(${CMAKE_CURRENT_LIST_DIR}/flags-gcc.cmake) \ No newline at end of file diff --git a/cmake/flags-gcc-armv7.cmake b/cmake/flags-gcc-armv7.cmake index 4ee436c35..bd49fdfce 100644 --- a/cmake/flags-gcc-armv7.cmake +++ b/cmake/flags-gcc-armv7.cmake @@ -14,7 +14,7 @@ # Copyright 2021 David Hrdlička. # -include(${CMAKE_CURRENT_LIST_DIR}/flags-gcc.cmake) +string(APPEND CMAKE_C_FLAGS_INIT " -march=armv7-a -mfloat-abi=hard ${CMAKE_C_FLAGS_INIT}") +string(APPEND CMAKE_CXX_FLAGS_INIT " -march=armv7-a -mfloat-abi=hard ${CMAKE_CXX_FLAGS_INIT}") -set(CMAKE_C_FLAGS_INIT "-march=armv7-a -mfloat-abi=hard ${CMAKE_C_FLAGS_INIT}") -set(CMAKE_CXX_FLAGS_INIT "-march=armv7-a -mfloat-abi=hard ${CMAKE_CXX_FLAGS_INIT}") \ No newline at end of file +include(${CMAKE_CURRENT_LIST_DIR}/flags-gcc.cmake) \ No newline at end of file diff --git a/cmake/flags-gcc-i686.cmake b/cmake/flags-gcc-i686.cmake index 9c508f17b..6d1afd6a9 100644 --- a/cmake/flags-gcc-i686.cmake +++ b/cmake/flags-gcc-i686.cmake @@ -14,7 +14,7 @@ # Copyright 2021 David Hrdlička. # -include(${CMAKE_CURRENT_LIST_DIR}/flags-gcc.cmake) +string(APPEND CMAKE_C_FLAGS_INIT " -m32 -march=i686 -msse2 -mfpmath=sse ${CMAKE_C_FLAGS_INIT}") +string(APPEND CMAKE_CXX_FLAGS_INIT " -m32 -march=i686 -msse2 -mfpmath=sse ${CMAKE_CXX_FLAGS_INIT}") -set(CMAKE_C_FLAGS_INIT "-m32 -march=i686 -msse2 -mfpmath=sse ${CMAKE_C_FLAGS_INIT}") -set(CMAKE_CXX_FLAGS_INIT "-m32 -march=i686 -msse2 -mfpmath=sse ${CMAKE_CXX_FLAGS_INIT}") \ No newline at end of file +include(${CMAKE_CURRENT_LIST_DIR}/flags-gcc.cmake) diff --git a/cmake/flags-gcc-x86_64.cmake b/cmake/flags-gcc-x86_64.cmake index 4edd2ec79..e373a1fec 100644 --- a/cmake/flags-gcc-x86_64.cmake +++ b/cmake/flags-gcc-x86_64.cmake @@ -14,7 +14,7 @@ # Copyright 2021 David Hrdlička. # -include(${CMAKE_CURRENT_LIST_DIR}/flags-gcc.cmake) +string(APPEND CMAKE_C_FLAGS_INIT " -m64 -march=x86-64 -msse2 -mfpmath=sse ${CMAKE_C_FLAGS_INIT}") +string(APPEND CMAKE_CXX_FLAGS_INIT " -m64 -march=x86-64 -msse2 -mfpmath=sse ${CMAKE_CXX_FLAGS_INIT}") -set(CMAKE_C_FLAGS_INIT "-m64 -march=x86-64 -msse2 -mfpmath=sse ${CMAKE_C_FLAGS_INIT}") -set(CMAKE_CXX_FLAGS_INIT "-m64 -march=x86-64 -msse2 -mfpmath=sse ${CMAKE_CXX_FLAGS_INIT}") \ No newline at end of file +include(${CMAKE_CURRENT_LIST_DIR}/flags-gcc.cmake) diff --git a/cmake/flags-gcc.cmake b/cmake/flags-gcc.cmake index bebe58f2a..266b70d44 100644 --- a/cmake/flags-gcc.cmake +++ b/cmake/flags-gcc.cmake @@ -13,13 +13,23 @@ # Copyright 2021 David Hrdlička. # -set(CMAKE_CONFIGURATION_TYPES Debug;Release;Optimized) +# Define our flags +string(APPEND CMAKE_C_FLAGS_INIT " -fomit-frame-pointer -mstackrealign -Wall -fno-strict-aliasing") +string(APPEND CMAKE_CXX_FLAGS_INIT " -fomit-frame-pointer -mstackrealign -Wall -fno-strict-aliasing") +string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -g0 -O3") +string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " -g0 -O3") +string(APPEND CMAKE_C_FLAGS_DEBUG_INIT " -ggdb -Og") +string(APPEND CMAKE_CXX_FLAGS_DEBUG_INIT " -ggdb -Og") +string(APPEND CMAKE_C_FLAGS_OPTIMIZED_INIT " -march=native -mtune=native -O3 -ffp-contract=fast -flto") +string(APPEND CMAKE_CXX_FLAGS_OPTIMIZED_INIT " -march=native -mtune=native -O3 -ffp-contract=fast -flto") -set(CMAKE_C_FLAGS_INIT "-fomit-frame-pointer -mstackrealign -Wall -fno-strict-aliasing") -set(CMAKE_CXX_FLAGS_INIT ${CMAKE_C_FLAGS_INIT}) -set(CMAKE_C_FLAGS_RELEASE_INIT "-g0 -O3") -set(CMAKE_CXX_FLAGS_RELEASE_INIT ${CMAKE_C_FLAGS_RELEASE_INIT}) -set(CMAKE_C_FLAGS_DEBUG_INIT "-ggdb -Og") -set(CMAKE_CXX_FLAGS_DEBUG_INIT ${CMAKE_C_FLAGS_DEBUG_INIT}) -set(CMAKE_C_FLAGS_OPTIMIZED_INIT "-march=native -mtune=native -O3 -ffp-contract=fast -flto") -set(CMAKE_CXX_FLAGS_OPTIMIZED_INIT ${CMAKE_C_FLAGS_OPTIMIZED_INIT}) \ No newline at end of file +# Set up the variables +foreach(LANG C;CXX) + set(CMAKE_${LANG}_FLAGS "$ENV{${LANG}FLAGS} ${CMAKE_${LANG}_FLAGS_INIT}" CACHE STRING "Flags used by the ${LANG} compiler during all build types.") + mark_as_advanced(CMAKE_${LANG}_FLAGS) + + foreach(CONFIG RELEASE;DEBUG;OPTIMIZED) + set(CMAKE_${LANG}_FLAGS_${CONFIG} "${CMAKE_${LANG}_FLAGS_${CONFIG}_INIT}" CACHE STRING "Flags used by the ${LANG} compiler during ${CONFIG} builds.") + mark_as_advanced(CMAKE_${LANG}_FLAGS_${CONFIG}) + endforeach() +endforeach() \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c85246a49..47d48e4a2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -64,9 +64,11 @@ if(WIN32 AND ARCH STREQUAL "i386") endif() endif() -if(MINGW) - target_link_options(86Box PRIVATE "-static") - set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" ".dll.a") +if(STATIC_BUILD) + if(MINGW OR UNIX) + target_link_options(86Box PRIVATE "-static") + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") + endif() endif() if(APPLE) @@ -104,7 +106,7 @@ target_link_libraries(86Box ${OPENAL_LIBRARY}) find_package(SDL2 REQUIRED) include_directories(${SDL2_INCLUDE_DIRS}) -if(WIN32 AND TARGET SDL2::SDL2-static) +if(STATIC_BUILD AND TARGET SDL2::SDL2-static) target_link_libraries(86Box SDL2::SDL2-static) elseif(TARGET SDL2::SDL2) target_link_libraries(86Box SDL2::SDL2) @@ -156,7 +158,7 @@ if(MINITRACE) target_link_libraries(86Box minitrace) endif() -if(WIN32 OR APPLE) +if(WIN32 OR (APPLE AND CMAKE_MACOSX_BUNDLE)) # Copy the binary to the root of the install prefix on Windows and macOS install(TARGETS 86Box DESTINATION ".") else() diff --git a/src/win/languages/pt-BR.rc b/src/win/languages/pt-BR.rc index 44968872e..06a000458 100644 --- a/src/win/languages/pt-BR.rc +++ b/src/win/languages/pt-BR.rc @@ -9,6 +9,8 @@ LANGUAGE LANG_PORTUGUESE, SUBLANG_PORTUGUESE_BRAZILIAN #pragma code_page(65001) #endif //_WIN32 +#define AUTHORS + ///////////////////////////////////////////////////////////////////////////// // // Menu @@ -78,12 +80,12 @@ BEGIN POPUP "&Tipo de tela VGA" BEGIN MENUITEM "&Cor RGB", IDM_VID_GRAY_RGB - MENUITEM "Escala de cinza &RGB", IDM_VID_GRAY_MONO + MENUITEM "Tons de cinza &RGB", IDM_VID_GRAY_MONO MENUITEM "Monitor &âmbar", IDM_VID_GRAY_AMBER MENUITEM "Monitor &verde", IDM_VID_GRAY_GREEN MENUITEM "Monitor &branco", IDM_VID_GRAY_WHITE END - POPUP "Tipo de &conversão de escala de cinza" + POPUP "Tipo de &conversão de tons de cinza" BEGIN MENUITEM "BT&601 (NTSC/PAL)", IDM_VID_GRAYCT_601 MENUITEM "BT&709 (HDTV)", IDM_VID_GRAYCT_709 @@ -531,8 +533,8 @@ BEGIN IDS_2149 "Imagens de cassete (*.PCM;*.RAW;*.WAV;*.CAS)\0*.PCM;*.RAW;*.WAV;*.CAS\0Todos os arquivos (*.*)\0*.*\0" IDS_2150 "Cartucho %i: %ls" IDS_2151 "Imagens de cartucho (*.A;*.B;*.JRC)\0*.A;*.B;*.JRC\0Todos os arquivos (*.*)\0*.*\0" - IDS_2152 "Error initializing renderer" - IDS_2153 "OpenGL (3.0 Core) renderer could not be initialized. Use another renderer." + IDS_2152 "Erro ao inicializar o renderizador" + IDS_2153 "O renderizador OpenGL (Núcleo 3.0) não pôde ser inicializado. Use outro renderizador." END STRINGTABLE DISCARDABLE