Skip to content

Commit 7318eef

Browse files
committed
default build is optimized
1 parent d6848cd commit 7318eef

File tree

2 files changed

+55
-36
lines changed

2 files changed

+55
-36
lines changed

CMakeLists.txt

+15
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
55
cmake -Bbuild")
66
endif()
77

8+
if(NOT MSVC)
9+
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
10+
if(is_multi_config)
11+
message(WARNING "Please use single config generator to avoid problems")
12+
endif()
13+
endif()
14+
15+
if(NOT CMAKE_BUILD_TYPE)
16+
if(DEFINED ENV{CMAKE_BUILD_TYPE})
17+
set(CMAKE_BUILD_TYPE $ENV{CMAKE_BUILD_TYPE} CACHE STRING "default")
18+
else()
19+
set(CMAKE_BUILD_TYPE Release CACHE STRING "Release default")
20+
endif()
21+
endif()
22+
823
# -- must override compiler to be gcc on Linux and clang on Macos.
924
# otherwise, Autotools is too shaky.
1025
# Intel compiler icx/icpx works but is more than 100x slower to build.

python.cmake

+40-36
Original file line numberDiff line numberDiff line change
@@ -19,44 +19,48 @@ if(WIN32)
1919
# https://discuss.python.org/t/windows-install-from-source-failing/25389/4
2020
# --precompile causes problem with script hard-coded temporary directory
2121

22-
else()
23-
# Linux prereqs: https://devguide.python.org/setup/#linux
24-
25-
# prereqs
26-
foreach(l IN ITEMS bzip2 expat ffi lzma readline ssl zlib)
27-
include(${l}.cmake)
28-
endforeach()
29-
30-
# Python build
31-
set(python_args
32-
--prefix=${CMAKE_INSTALL_PREFIX}
33-
CC=${CC}
34-
--with-system-expat
35-
)
36-
if(CMAKE_BUILD_TYPE STREQUAL "Release")
37-
list(APPEND python_args --enable-optimizations)
38-
endif()
22+
return()
23+
endif()
3924

40-
set(python_cflags "${CMAKE_C_FLAGS}")
41-
set(python_ldflags "${LDFLAGS}")
25+
# Linux prereqs: https://devguide.python.org/setup/#linux
4226

43-
if(OPENSSL_FOUND)
44-
get_filename_component(openssl_dir ${OPENSSL_INCLUDE_DIR} DIRECTORY)
45-
list(APPEND python_args --with-openssl=${openssl_dir})
46-
else()
47-
list(APPEND python_args --with-openssl=${CMAKE_INSTALL_PREFIX})
48-
endif()
27+
# prereqs
28+
foreach(l IN ITEMS bzip2 expat ffi lzma readline ssl zlib)
29+
include(${l}.cmake)
30+
endforeach()
4931

50-
ExternalProject_Add(python
51-
${python_download}
52-
CONFIGURE_COMMAND <SOURCE_DIR>/configure ${python_args} CFLAGS=${python_cflags} LDFLAGS=${python_ldflags}
53-
BUILD_COMMAND ${MAKE_EXECUTABLE} -j
54-
INSTALL_COMMAND ${MAKE_EXECUTABLE} -j install
55-
TEST_COMMAND ""
56-
CONFIGURE_HANDLED_BY_BUILD ON
57-
INACTIVITY_TIMEOUT 60
58-
DEPENDS "bzip2;expat;ffi;readline;ssl;xz;zlib"
59-
${terminal_verbose}
60-
)
32+
# Python build
33+
set(python_args
34+
--prefix=${CMAKE_INSTALL_PREFIX}
35+
CC=${CC}
36+
--with-system-expat
37+
)
38+
if(CMAKE_BUILD_TYPE STREQUAL "Release")
39+
list(APPEND python_args --enable-optimizations)
40+
endif()
6141

42+
set(python_cflags "${CMAKE_C_FLAGS}")
43+
set(python_ldflags "${LDFLAGS}")
44+
45+
if(OPENSSL_FOUND)
46+
get_filename_component(openssl_dir ${OPENSSL_INCLUDE_DIR} DIRECTORY)
47+
list(APPEND python_args --with-openssl=${openssl_dir})
48+
else()
49+
list(APPEND python_args --with-openssl=${CMAKE_INSTALL_PREFIX})
6250
endif()
51+
52+
message(STATUS "Python configure args: ${python_args}")
53+
message(STATUS "Python CFLAGS: ${python_cflags}")
54+
message(STATUS "Python LDFLAGS: ${python_ldflags}")
55+
56+
ExternalProject_Add(python
57+
${python_download}
58+
CONFIGURE_COMMAND <SOURCE_DIR>/configure ${python_args} CFLAGS=${python_cflags} LDFLAGS=${python_ldflags}
59+
BUILD_COMMAND ${MAKE_EXECUTABLE} -j
60+
INSTALL_COMMAND ${MAKE_EXECUTABLE} -j install
61+
TEST_COMMAND ""
62+
CONFIGURE_HANDLED_BY_BUILD ON
63+
INACTIVITY_TIMEOUT 60
64+
DEPENDS "bzip2;expat;ffi;readline;ssl;xz;zlib"
65+
${terminal_verbose}
66+
)

0 commit comments

Comments
 (0)