1. 14 Feb, 2017 3 commits
    • Dean Moldovan's avatar
      d361ea15
    • Jason Rhinelander's avatar
      Store LTO flags in PYBIND11_LTO_{CXX,LINKER}_FLAGS cache variables · c137c0a8
      Jason Rhinelander authored
      This both lets us not bother rechecking LTO flags when cmake reinvokes
      itself, and also lets the cmake invoker override to specify custom or
      no LTO flags by setting the cache variable with
      -DPYBIND11_LTO_CXX_FLAGS= when invoking cmake.
      c137c0a8
    • Jason Rhinelander's avatar
      Overhaul LTO flag detection · 1bee6e7d
      Jason Rhinelander authored
      Clang on linux currently fails to run cmake:
      
          $ CC=clang CXX=clang++ cmake ..
          ...
          -- Configuring done
          CMake Error at tools/pybind11Tools.cmake:135 (target_compile_options):
            Error evaluating generator expression:
      
              $<:-flto>
      
            Expression did not evaluate to a known generator expression
          Call Stack (most recent call first):
            tests/CMakeLists.txt:68 (pybind11_add_module)
      
      But investigating this led to various other -flto detection problems;
      this commit thus overhauls LTO flag detection:
      
      - -flto needs to be passed to the linker as well
      - Also compile with -fno-fat-lto-objects under GCC
      - Pass the equivalent flags to MSVC
      - Enable LTO flags for via generator expressions (for non-debug builds
        only), so that multi-config builds (like on Windows) still work
        properly.  This seems reasonable, however, even on single-config
        builds (and simplifies the cmake code a bit).
      - clang's lto linker plugins don't accept '-Os', so replace it with
        '-O3' when doing a MINSIZEREL build
      - Enable trying ThinLTO by default for test suite (only affects clang)
      - Match Clang$ rather than ^Clang$ because, for cmake with 3.0+
        policies in effect, the compiler ID will be AppleClang on macOS.
      1bee6e7d
  2. 06 Jan, 2017 2 commits
  3. 19 Dec, 2016 2 commits
    • Dean Moldovan's avatar
      Add new options and docs for pybind11_add_module · 0cbec5c9
      Dean Moldovan authored
      See the documentation for a description of the options.
      0cbec5c9
    • Dean Moldovan's avatar
      Make sure add_subdirectory and find_package behave identically · b0f3885c
      Dean Moldovan authored
      Add a BUILD_INTERFACE and a pybind11::pybind11 alias for the interface
      library to match the installed target.
      
      Add new cmake tests for add_subdirectory and consolidates the
      .cpp and .py files needed for the cmake build tests:
      
      Before:
      tests
      |-- test_installed_module
      |   |-- CMakeLists.txt
      |   |-- main.cpp
      |   \-- test.py
      \-- test_installed_target
          |-- CMakeLists.txt
          |-- main.cpp
          \-- test.py
      
      After:
      tests
      \-- test_cmake_build
          |-- installed_module/CMakeLists.txt
          |-- installed_target/CMakeLists.txt
          |-- subdirectory_module/CMakeLists.txt
          |-- subdirectory_target/CMakeLists.txt
          |-- main.cpp
          \-- test.py
      b0f3885c
  4. 13 Dec, 2016 1 commit