@@ -5,11 +5,6 @@ project(GeneticAlgorithm VERSION 1.0.0 LANGUAGES CXX)
55set (CMAKE_CXX_STANDARD 17)
66set (CMAKE_CXX_STANDARD_REQUIRED ON )
77
8- # Set compiler flags
9- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra" )
10- set (CMAKE_CXX_FLAGS_RELEASE "-O3" )
11- set (CMAKE_CXX_FLAGS_DEBUG "-g -O0" )
12-
138# Include directories
149include_directories (${CMAKE_SOURCE_DIR} )
1510include_directories (${CMAKE_SOURCE_DIR} /include )
@@ -38,6 +33,13 @@ target_include_directories(genetic_algorithm PUBLIC
3833)
3934set_target_properties (genetic_algorithm PROPERTIES OUTPUT_NAME "genetic_algorithm" )
4035
36+ # Warnings: keep them compiler-appropriate (avoid injecting GCC/Clang flags into MSVC).
37+ if (MSVC )
38+ target_compile_options (genetic_algorithm PRIVATE /W4 )
39+ else ()
40+ target_compile_options (genetic_algorithm PRIVATE -Wall -Wextra )
41+ endif ()
42+
4143if (NOT SKBUILD)
4244 # Main executable
4345 add_executable (simple-ga-test
@@ -163,9 +165,12 @@ endif()
163165# ---------------------------------------------------------------- Python bindings
164166# When building a Python wheel (SKBUILD=ON), Python bindings are required.
165167if (SKBUILD)
166- find_package (Python3 REQUIRED COMPONENTS Interpreter Development )
168+ # Manylinux Python distributions used by cibuildwheel do not ship libpython
169+ # (Development.Embed / Python3_LIBRARIES). For extension modules we only
170+ # need headers + module build info.
171+ find_package (Python3 REQUIRED COMPONENTS Interpreter Development.Module )
167172else ()
168- find_package (Python3 COMPONENTS Interpreter Development QUIET )
173+ find_package (Python3 COMPONENTS Interpreter Development.Module QUIET )
169174endif ()
170175
171176# Try to locate pybind11 via its CMake config (installed via pip or system).
@@ -195,6 +200,13 @@ if(Python3_FOUND AND pybind11_FOUND)
195200 target_sources (ga_python_module PRIVATE benchmark/ga_benchmark.cc )
196201 target_link_libraries (ga_python_module PRIVATE genetic_algorithm )
197202 target_include_directories (ga_python_module PRIVATE ${CMAKE_SOURCE_DIR} /include )
203+
204+ if (MSVC )
205+ target_compile_options (ga_python_module PRIVATE /W4 )
206+ else ()
207+ target_compile_options (ga_python_module PRIVATE -Wall -Wextra )
208+ endif ()
209+
198210 set_target_properties (ga_python_module PROPERTIES
199211 OUTPUT_NAME "_core"
200212 LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR} /python"
0 commit comments