From 838851f55a651fc8091f8f721b8cd70aacd57609 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 3 Jun 2016 20:26:58 -0400 Subject: [PATCH] Started the gcc stuff. Doesn't work on Windows; too much to fix. --- CMakeLists.txt | 14 +++++++++++++- migrate_build/CMakeLists.txt | 3 --- migrate_build/build/GNUbasegcc.mk | 21 --------------------- migrate_build/build/GNUmakefile.libui | 2 +- 4 files changed, 14 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 15367662..e039fd9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 2.8.11) # TODOs: -# - MSVC static linking does not include the .res file in out\, so executables lack the necessary +# - MSVC static linking does not include the .res file in out\, so executables lack the necessary resources +# - same thing with MinGW? +# - MinGW doesn't work in general; windres doesn't like _UI_EXTERN (we could mitigate this by moving the stuff into ui.h and taking advantage of the libui_EXPORTS macro cmake makes for us) but project(libui LANGUAGES C CXX) option(BUILD_SHARED_LIBS "Whether to build libui as a shared library or a static library" ON) @@ -55,6 +57,16 @@ if(MSVC) # TODO autogenerate a .def file? else() + set(_COMMON_CFLAGS + -Wall -Wextra -pedantic + -Wno-unused-parameter + -Wno-switch + -fvisibility=hidden + ) + # don't use C_VERSION or CXX_VERSION because they use GNU standards + string(APPEND CMAKE_C_FLAGS " --std=c99") + string(APPEND CMAKE_CXX_FLAGS " --std=c++11") + endif() # problem: diff --git a/migrate_build/CMakeLists.txt b/migrate_build/CMakeLists.txt index 130eaeea..7ae649d2 100644 --- a/migrate_build/CMakeLists.txt +++ b/migrate_build/CMakeLists.txt @@ -114,9 +114,6 @@ if(MSVC) else() append2(CMAKE_C_FLAGS CMAKE_CXX_FLAGS " -Wall -Wextra -pedantic -Wno-unused-parameter -Wno-switch") - # don't use C_VERSION or CXX_VERSION because they use GNU standards - append(CMAKE_C_FLAGS " --std=c99") - append(CMAKE_CXX_FLAGS " --std=c++11") if(NOT WIN32) append(CMAKE_C_FLAGS_DEBUG " -fPIC") diff --git a/migrate_build/build/GNUbasegcc.mk b/migrate_build/build/GNUbasegcc.mk index 9e3e8636..6e834d15 100644 --- a/migrate_build/build/GNUbasegcc.mk +++ b/migrate_build/build/GNUbasegcc.mk @@ -3,32 +3,11 @@ # Global flags. CFLAGS += \ - -Wall -Wextra -pedantic \ - -Wno-unused-parameter \ - -Wno-switch \ --std=c99 -# C++11 is needed due to stupid rules involving commas at the end of enum lists that C++03 stupidly didn't follow -# This means sorry, no GCC 2 for Haiku builds :( CXXFLAGS += \ - -Wall -Wextra -pedantic \ - -Wno-unused-parameter \ - -Wno-switch \ --std=c++11 -# -fPIC shouldn't be used with static builds (see https://github.com/andlabs/libui/issues/72#issuecomment-222395547) -ifeq (,$(STATIC)) -CFLAGS += -fPIC -CXXFLAGS += -fPIC -LDFLAGS += -fPIC -endif - -ifneq ($(RELEASE),1) - CFLAGS += -g - CXXFLAGS += -g - LDFLAGS += -g -endif - # Build rules. OFILES = \ diff --git a/migrate_build/build/GNUmakefile.libui b/migrate_build/build/GNUmakefile.libui index 34f2af12..c4ac54d3 100644 --- a/migrate_build/build/GNUmakefile.libui +++ b/migrate_build/build/GNUmakefile.libui @@ -27,7 +27,7 @@ SUFFIX = $(STATICLIBSUFFIX) endif ifeq ($(TOOLCHAIN),gcc) - -fvisibility=hidden + LDFLAGS += \ -fvisibility=hidden else