Skip to content

Commit 518cf72

Browse files
author
Wenzel Jakob
committed
improve cmake windows debug configuration (fixes #77)
1 parent fa92f67 commit 518cf72

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

CMakeLists.txt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,17 @@ endforeach()
129129

130130
if (WIN32)
131131
if (MSVC)
132-
# Enforce size-based optimization and link time code generation
133-
# on MSVC (~30% smaller binaries in experiments). /bigobj is needed
134-
# for bigger binding projects due to the limit to 64k addressable sections
135-
# /MP enables multithreaded builds (relevant when there are many files).
136-
set_target_properties(example PROPERTIES COMPILE_FLAGS "/Os /GL /MP /bigobj")
137-
set_target_properties(example PROPERTIES LINK_FLAGS "/LTCG")
132+
# /bigobj is needed for bigger binding projects due to the limit to 64k
133+
# addressable sections. /MP enables multithreaded builds (relevant when
134+
# there are many files).
135+
set_target_properties(example PROPERTIES COMPILE_FLAGS "/MP /bigobj ")
136+
137+
if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG)
138+
# Enforce size-based optimization and link time code generation on MSVC
139+
# (~30% smaller binaries in experiments).
140+
set_target_properties(example APPEND_STRING PROPERTY COMPILE_FLAGS "/Os /GL ")
141+
set_target_properties(example APPEND_STRING PROPERTY LINK_FLAGS "/LTCG ")
142+
endif()
138143
endif()
139144

140145
# .PYD file extension on Windows
@@ -151,7 +156,7 @@ elseif (UNIX)
151156
# conflicting Python instances are active at the same time (even when they
152157
# are of the same version).
153158

154-
# Windows is not affected by this issue since it handles DLL imports
159+
# Windows is not affected by this issue since it handles DLL imports
155160
# differently. The solution for Linux and Mac OS is simple: we just don't
156161
# link against the Python library. The resulting shared library will have
157162
# missing symbols, but that's perfectly fine -- they will be resolved at

docs/cmake.rst

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,17 @@ and that the pybind11 repository is located in a subdirectory named :file:`pybin
8484
8585
if (WIN32)
8686
if (MSVC)
87-
# Enforce size-based optimization and link time code generation
88-
# on MSVC (~30% smaller binaries in experiments). /bigobj is needed
89-
# for bigger binding projects due to the limit to 64k addressable sections
90-
# /MP enables multithreaded builds (relevant when there are many files).
91-
set_target_properties(example PROPERTIES COMPILE_FLAGS "/Os /GL /MP /bigobj")
92-
set_target_properties(example PROPERTIES LINK_FLAGS "/LTCG")
87+
# /bigobj is needed for bigger binding projects due to the limit to 64k
88+
# addressable sections. /MP enables multithreaded builds (relevant when
89+
# there are many files).
90+
set_target_properties(example PROPERTIES COMPILE_FLAGS "/MP /bigobj ")
91+
92+
if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG)
93+
# Enforce size-based optimization and link time code generation on MSVC
94+
# (~30% smaller binaries in experiments).
95+
set_target_properties(example APPEND_STRING PROPERTY COMPILE_FLAGS "/Os /GL ")
96+
set_target_properties(example APPEND_STRING PROPERTY LINK_FLAGS "/LTCG ")
97+
endif()
9398
endif()
9499
95100
# .PYD file extension on Windows

0 commit comments

Comments
 (0)