From 39f2699b90174dcfb0bad2525f35375915cdd0f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 11 Jun 2019 15:05:04 +0200 Subject: [PATCH] python: more yelling at the buildsystem. --- package/ci/setup-pybind11.sh | 6 ++++-- src/python/CMakeLists.txt | 14 +++++++++++++- src/python/corrade/CMakeLists.txt | 4 ++-- src/python/magnum/CMakeLists.txt | 14 +++++++------- src/python/magnum/platform/CMakeLists.txt | 8 ++++---- 5 files changed, 30 insertions(+), 16 deletions(-) diff --git a/package/ci/setup-pybind11.sh b/package/ci/setup-pybind11.sh index dcf96da..da2327a 100755 --- a/package/ci/setup-pybind11.sh +++ b/package/ci/setup-pybind11.sh @@ -7,8 +7,10 @@ cd pybind11-2.2.4 # Patch the CMake macro to add include paths as SYSTEM because otherwise GCC # 4.8 gets very loud. This is already done in # https://github.com/pybind/pybind11/pull/1416 but it's opt-in and not part of -# any release yet. I don't want to force users to use pybind11 git, so apply -# a patch manually. +# any release yet. For Git releases this is handled inside +# src/python/CMakeLists.txt (detecting version and applying SYSTEM), but I want +# to ensure compatibility with 2.2.4 *and* have useful CI output, so I am +# patching it here as well. patch -p1 < $TRAVIS_BUILD_DIR/package/ci/pybind11-system-includes.patch mkdir -p build && cd build diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index c28e5dd..47a6ef1 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -26,9 +26,21 @@ # Thanks, CMake, for making the recommended way of installing pacakges so # useless that it's impossible to call find_package() consistently independent # of whether it's installed system-wide or added through add_subdirectory(). -# This is absolutely awful. +# This also means we can't use pybind11_VERSION below but have to extract it +# from some private cache variables instead. THIS IS ABSOLUTELY AWFUL, FFS. if(NOT COMMAND pybind11_add_module) find_package(pybind11 CONFIG REQUIRED) +elseif(NOT pybind11_VERSION) + set(pybind11_VERSION ${PYBIND11_VERSION_MAJOR}.${PYBIND11_VERSION_MINOR}.${PYBIND11_VERSION_PATCH}) +endif() + +# By default, pybind11_add_module() adds the include directories as non-system. +# That, combined with Corrade's warning level, adds an insane amount of +# warnings to the build. Since https://github.com/pybind/pybind11/pull/1416 +# (scheduled to release in 2.3) it's possible to override that by passing +# SYSTEM to pybind11_add_module(). +if(NOT pybind11_VERSION VERSION_LESS 2.3) + set(pybind11_add_module_SYSTEM SYSTEM) endif() # UGH FFS diff --git a/src/python/corrade/CMakeLists.txt b/src/python/corrade/CMakeLists.txt index ffe5da6..1cdd94c 100644 --- a/src/python/corrade/CMakeLists.txt +++ b/src/python/corrade/CMakeLists.txt @@ -29,7 +29,7 @@ set(corrade_containers_SRCS # If Corrade is not built as static, compile the sub-libraries as separate # modules if(NOT CORRADE_BUILD_STATIC) - pybind11_add_module(corrade_containers ${corrade_containers_SRCS}) + pybind11_add_module(corrade_containers ${pybind11_add_module_SYSTEM} ${corrade_containers_SRCS}) target_include_directories(corrade_containers PRIVATE ${PROJECT_SOURCE_DIR}/src/python) target_link_libraries(corrade_containers PRIVATE Corrade::Containers @@ -47,7 +47,7 @@ else() corrade.cpp ${corrade_containers_SRCS}) - pybind11_add_module(corrade ${corrade_SRCS}) + pybind11_add_module(corrade ${pybind11_add_module_SYSTEM} ${corrade_SRCS}) target_include_directories(corrade PRIVATE ${PROJECT_SOURCE_DIR}/src/python) target_link_libraries(corrade PRIVATE Corrade::Utility ${corrade_LIBS}) set_target_properties(corrade PROPERTIES diff --git a/src/python/magnum/CMakeLists.txt b/src/python/magnum/CMakeLists.txt index 1920e84..5244149 100644 --- a/src/python/magnum/CMakeLists.txt +++ b/src/python/magnum/CMakeLists.txt @@ -72,7 +72,7 @@ set(magnum_trade_SRCS # modules if(NOT MAGNUM_BUILD_STATIC) if(Magnum_GL_FOUND) - pybind11_add_module(magnum_gl ${magnum_gl_SRCS}) + pybind11_add_module(magnum_gl ${pybind11_add_module_SYSTEM} ${magnum_gl_SRCS}) target_include_directories(magnum_gl PRIVATE ${PROJECT_SOURCE_DIR}/src/python) target_link_libraries(magnum_gl PRIVATE Magnum::GL) set_target_properties(magnum_gl PROPERTIES @@ -82,7 +82,7 @@ if(NOT MAGNUM_BUILD_STATIC) endif() if(Magnum_MeshTools_FOUND) - pybind11_add_module(magnum_meshtools ${magnum_meshtools_SRCS}) + pybind11_add_module(magnum_meshtools ${pybind11_add_module_SYSTEM} ${magnum_meshtools_SRCS}) target_include_directories(magnum_meshtools PRIVATE ${PROJECT_SOURCE_DIR}/src/python) target_link_libraries(magnum_meshtools PRIVATE Magnum::MeshTools) set_target_properties(magnum_meshtools PROPERTIES @@ -92,7 +92,7 @@ if(NOT MAGNUM_BUILD_STATIC) endif() if(Magnum_Primitives_FOUND) - pybind11_add_module(magnum_primitives ${magnum_primitives_SRCS}) + pybind11_add_module(magnum_primitives ${pybind11_add_module_SYSTEM} ${magnum_primitives_SRCS}) target_include_directories(magnum_primitives PRIVATE ${PROJECT_SOURCE_DIR}/src/python) target_link_libraries(magnum_primitives PRIVATE Magnum::Primitives) set_target_properties(magnum_primitives PROPERTIES @@ -102,7 +102,7 @@ if(NOT MAGNUM_BUILD_STATIC) endif() if(Magnum_SceneGraph_FOUND) - pybind11_add_module(magnum_scenegraph ${magnum_scenegraph_SRCS}) + pybind11_add_module(magnum_scenegraph ${pybind11_add_module_SYSTEM} ${magnum_scenegraph_SRCS}) target_include_directories(magnum_scenegraph PRIVATE ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/src/python) @@ -114,7 +114,7 @@ if(NOT MAGNUM_BUILD_STATIC) endif() if(Magnum_Shaders_FOUND) - pybind11_add_module(magnum_shaders ${magnum_shaders_SRCS}) + pybind11_add_module(magnum_shaders ${pybind11_add_module_SYSTEM} ${magnum_shaders_SRCS}) target_include_directories(magnum_shaders PRIVATE ${PROJECT_SOURCE_DIR}/src/python) target_link_libraries(magnum_shaders PRIVATE Magnum::Shaders) set_target_properties(magnum_shaders PROPERTIES @@ -124,7 +124,7 @@ if(NOT MAGNUM_BUILD_STATIC) endif() if(Magnum_Trade_FOUND) - pybind11_add_module(magnum_trade ${magnum_trade_SRCS}) + pybind11_add_module(magnum_trade ${pybind11_add_module_SYSTEM} ${magnum_trade_SRCS}) target_include_directories(magnum_trade PRIVATE ${PROJECT_SOURCE_DIR}/src/python) target_link_libraries(magnum_trade PRIVATE Magnum::Trade) set_target_properties(magnum_trade PROPERTIES @@ -191,7 +191,7 @@ else() endif() endif() -pybind11_add_module(magnum ${magnum_SRCS}) +pybind11_add_module(magnum ${pybind11_add_module_SYSTEM} ${magnum_SRCS}) target_include_directories(magnum PRIVATE ${PROJECT_SOURCE_DIR}/src # SceneGraph/Python.h for static build ${PROJECT_SOURCE_DIR}/src/python diff --git a/src/python/magnum/platform/CMakeLists.txt b/src/python/magnum/platform/CMakeLists.txt index bb61f3f..70b234a 100644 --- a/src/python/magnum/platform/CMakeLists.txt +++ b/src/python/magnum/platform/CMakeLists.txt @@ -25,7 +25,7 @@ if(NOT MAGNUM_BUILD_STATIC) if(Magnum_GlfwApplication_FOUND) - pybind11_add_module(magnum_platform_glfw glfw.cpp) + pybind11_add_module(magnum_platform_glfw ${pybind11_add_module_SYSTEM} glfw.cpp) target_link_libraries(magnum_platform_glfw PRIVATE Magnum::GlfwApplication) target_include_directories(magnum_platform_glfw PRIVATE ${CMAKE_SOURCE_DIR}/src/python) set_target_properties(magnum_platform_glfw PROPERTIES @@ -35,7 +35,7 @@ if(NOT MAGNUM_BUILD_STATIC) endif() if(Magnum_Sdl2Application_FOUND) - pybind11_add_module(magnum_platform_sdl2 sdl2.cpp) + pybind11_add_module(magnum_platform_sdl2 ${pybind11_add_module_SYSTEM} sdl2.cpp) target_link_libraries(magnum_platform_sdl2 PRIVATE Magnum::Sdl2Application) target_include_directories(magnum_platform_sdl2 PRIVATE ${CMAKE_SOURCE_DIR}/src/python) set_target_properties(magnum_platform_sdl2 PROPERTIES @@ -45,7 +45,7 @@ if(NOT MAGNUM_BUILD_STATIC) endif() if(Magnum_WindowlessEglApplication_FOUND) - pybind11_add_module(magnum_platform_egl egl.cpp) + pybind11_add_module(magnum_platform_egl ${pybind11_add_module_SYSTEM} egl.cpp) target_link_libraries(magnum_platform_egl PRIVATE Magnum::WindowlessEglApplication) target_include_directories(magnum_platform_egl PRIVATE ${PROJECT_SOURCE_DIR}/src/python) set_target_properties(magnum_platform_egl PROPERTIES @@ -55,7 +55,7 @@ if(NOT MAGNUM_BUILD_STATIC) endif() if(Magnum_WindowlessGlxApplication_FOUND) - pybind11_add_module(magnum_platform_glx glx.cpp) + pybind11_add_module(magnum_platform_glx ${pybind11_add_module_SYSTEM} glx.cpp) target_link_libraries(magnum_platform_glx PRIVATE Magnum::WindowlessGlxApplication) target_include_directories(magnum_platform_glx PRIVATE ${PROJECT_SOURCE_DIR}/src/python) set_target_properties(magnum_platform_glx PROPERTIES