From 3bcbc30697474cc32962856b6642ae0f6a17c8cc Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Fri, 18 Sep 2015 04:49:32 +0000 Subject: [PATCH 1/5] build: tinyxml2 needs module path set (like sdl2) --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 07dca08..95f5a6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -227,6 +227,7 @@ endif (NOT OPENAL_FOUND) OPTION(AQUARIA_INTERNAL_TINYXML2 "Always use included TinyXML2 library" ${WIN32_TRUE}) if(NOT AQUARIA_INTERNAL_TINYXML2) + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") find_package(TinyXML2) endif(NOT AQUARIA_INTERNAL_TINYXML2) if (AQUARIA_INTERNAL_TINYXML2 OR NOT TINYXML2_FOUND) From a888a44623e8ba7f1a3c00ace0ee49e6a6629b40 Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Fri, 18 Sep 2015 04:52:48 +0000 Subject: [PATCH 2/5] build: drop redundant check for bundled tinyxml2 --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 95f5a6e..fcb221e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -230,11 +230,11 @@ if(NOT AQUARIA_INTERNAL_TINYXML2) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") find_package(TinyXML2) endif(NOT AQUARIA_INTERNAL_TINYXML2) -if (AQUARIA_INTERNAL_TINYXML2 OR NOT TINYXML2_FOUND) +if(NOT TINYXML2_FOUND) message(STATUS "Using internal copy of TinyXML2") set(TINYXML2_INCLUDE_DIR "${EXTLIBDIR}") set(TINYXML2_SRCS "${EXTLIBDIR}/tinyxml2.cpp") -endif (AQUARIA_INTERNAL_TINYXML2 OR NOT TINYXML2_FOUND) +endif(NOT TINYXML2_FOUND) ################ End of external libraries From 451d27a1d5f9e910c1dd1ca2f28f9e4b8e07e85d Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Fri, 18 Sep 2015 04:55:42 +0000 Subject: [PATCH 3/5] build: make tinyxml2 export multiple include dirs like advertised --- CMakeLists.txt | 4 ++-- cmake/Modules/FindTinyXML2.cmake | 10 +++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fcb221e..b72e749 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,7 +232,7 @@ if(NOT AQUARIA_INTERNAL_TINYXML2) endif(NOT AQUARIA_INTERNAL_TINYXML2) if(NOT TINYXML2_FOUND) message(STATUS "Using internal copy of TinyXML2") - set(TINYXML2_INCLUDE_DIR "${EXTLIBDIR}") + set(TINYXML2_INCLUDE_DIRS "${EXTLIBDIR}") set(TINYXML2_SRCS "${EXTLIBDIR}/tinyxml2.cpp") endif(NOT TINYXML2_FOUND) @@ -249,7 +249,7 @@ INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${OGGVORBIS_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR}) -INCLUDE_DIRECTORIES(${TINYXML2_INCLUDE_DIR}) +INCLUDE_DIRECTORIES(${TINYXML2_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${EXTLIBDIR}) diff --git a/cmake/Modules/FindTinyXML2.cmake b/cmake/Modules/FindTinyXML2.cmake index e6ea7e6..7e00ab6 100644 --- a/cmake/Modules/FindTinyXML2.cmake +++ b/cmake/Modules/FindTinyXML2.cmake @@ -7,18 +7,14 @@ find_package(PkgConfig) pkg_check_modules(PC_TINYXML2 QUIET tinyxml2) +set(TINYXML2_INCLUDE_DIRS ${PC_TINYXML2_INCLUDE_DIRS}) set(TINYXML2_DEFINITIONS ${PC_TINYXML2_CFLAGS_OTHER}) -find_path(TINYXML2_INCLUDE_DIR tinyxml2.h - HINTS ${PC_TINYXML2_INCLUDEDIR} ${PC_TINYXML2_INCLUDE_DIRS}) - find_library(TINYXML2_LIBRARY NAMES tinyxml2 HINTS ${PC_TINYXML2_LIBDIR} ${PC_TINYXML2_LIBRARY_DIRS}) - set(TINYXML2_LIBRARIES ${TINYXML2_LIBRARY}) -set(TINYXML2_INCLUDE_DIRS ${TINYXML2_INCLUDE_DIR}) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(TinyXML2 DEFAULT_MSG TINYXML2_LIBRARY TINYXML2_INCLUDE_DIR) +find_package_handle_standard_args(TinyXML2 DEFAULT_MSG TINYXML2_LIBRARY TINYXML2_INCLUDE_DIRS) -mark_as_advanced(TINYXML2_INCLUDE_DIR TINYXML2_LIBRARY) +mark_as_advanced(TINYXML2_INCLUDE_DIRS TINYXML2_LIBRARY) From 2a31f932f92bbfd23b301661191fdacd9d26c703 Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Fri, 18 Sep 2015 05:00:20 +0000 Subject: [PATCH 4/5] build: add -DNDEBUG for Clang builds --- CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b72e749..5c5b396 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -317,6 +317,10 @@ ELSE(AQUARIA_DEMO_BUILD) ADD_DEFINITIONS(-DAQUARIA_BUILD_SCENEEDITOR=1) ENDIF(AQUARIA_DEMO_BUILD) +IF(CMAKE_BUILD_TYPE STREQUAL "Release") + ADD_DEFINITIONS(-DNDEBUG) # MSVC defines this in release mode by default, gcc/mingw do not + message(STATUS "This is a release build.") +ENDIF(CMAKE_BUILD_TYPE STREQUAL "Release") IF(CMAKE_BUILD_TYPE STREQUAL "Debug") ADD_DEFINITIONS(-D_DEBUG) # MSVC defines this in debug mode by default, gcc/mingw do not message(STATUS "This is a debug build.") @@ -358,8 +362,8 @@ IF(CMAKE_COMPILER_IS_GNUCC) # -O3 breaks on some GCC/MinGW versions, make sure CMake does not set this as default. # Exceptions are not used, excluding support for release builds adds less bulk as well. - set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG" CACHE STRING "Flags used for release builds" FORCE) - set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG -fno-exceptions" CACHE STRING "Flags used for release builds" FORCE) + set(CMAKE_C_FLAGS_RELEASE "-O2" CACHE STRING "Flags used for release builds" FORCE) + set(CMAKE_CXX_FLAGS_RELEASE "-O2 -fno-exceptions" CACHE STRING "Flags used for release builds" FORCE) # !!! FIXME: probably not safe long-term. # CMake mailing list had this hack for getting rid of -rdynamic: From 74d95c7ee8badd8c7198445a628fe2a153f871d5 Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Fri, 18 Sep 2015 05:16:57 +0000 Subject: [PATCH 5/5] build: make -Wno-invalid-offsetof more specific --- CMakeLists.txt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c5b396..32b3500 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -357,9 +357,6 @@ IF(CMAKE_COMPILER_IS_GNUCC) ADD_DEFINITIONS(-fno-stack-protector) ENDIF(AQUARIA_GCC_HAS_STACKPROT) - # We knowingly apply offsetof to non-POD types. - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-offsetof") - # -O3 breaks on some GCC/MinGW versions, make sure CMake does not set this as default. # Exceptions are not used, excluding support for release builds adds less bulk as well. set(CMAKE_C_FLAGS_RELEASE "-O2" CACHE STRING "Flags used for release builds" FORCE) @@ -451,6 +448,14 @@ SET(AQUARIA_SRCS_UNUSED ${SRCDIR}/WaterFont.cpp ) +IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) +SET_SOURCE_FILES_PROPERTIES( + # We knowingly apply offsetof to non-POD types. + ${SRCDIR}/ScriptInterface.cpp + PROPERTIES COMPILE_FLAGS "-Wno-invalid-offsetof" +) +ENDIF() + IF(MACOSX) IF(NOT AQUARIA_USE_SDL2) SET(COCOA_SRCS "${BBGEDIR}/Cocoa.mm")