Skip to content

Commit

Permalink
cmake: Fix macos 15 python build
Browse files Browse the repository at this point in the history
  • Loading branch information
Mizux committed Dec 18, 2024
1 parent 25d5c8b commit 1da3f34
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 89 deletions.
6 changes: 0 additions & 6 deletions ortools/algorithms/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ if(APPLE)
SUFFIX ".so"
INSTALL_RPATH "@loader_path;@loader_path/../../../${PYTHON_PROJECT}/.libs"
)
set_property(TARGET knapsack_solver_pybind11 APPEND PROPERTY
LINK_FLAGS "-flat_namespace -undefined suppress"
)
elseif(UNIX)
set_target_properties(knapsack_solver_pybind11 PROPERTIES
INSTALL_RPATH "$ORIGIN:$ORIGIN/../../../${PYTHON_PROJECT}/.libs"
Expand All @@ -45,9 +42,6 @@ if(APPLE)
SUFFIX ".so"
INSTALL_RPATH "@loader_path;@loader_path/../../../${PYTHON_PROJECT}/.libs"
)
set_property(TARGET set_cover_pybind11 APPEND PROPERTY
LINK_FLAGS "-flat_namespace -undefined suppress"
)
elseif(UNIX)
set_target_properties(set_cover_pybind11 PROPERTIES
INSTALL_RPATH "$ORIGIN:$ORIGIN/../../../${PYTHON_PROJECT}/.libs"
Expand Down
15 changes: 4 additions & 11 deletions ortools/constraint_solver/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,15 @@ set_target_properties(constraint_solver_pybind11 PROPERTIES
if(APPLE)
set_target_properties(constraint_solver_pybind11 PROPERTIES
SUFFIX ".so"
INSTALL_RPATH "@loader_path;@loader_path/../../../${PYTHON_PROJECT}/.libs"
)
set_property(TARGET constraint_solver_pybind11 APPEND PROPERTY
LINK_FLAGS "-flat_namespace -undefined suppress"
)
INSTALL_RPATH "@loader_path;@loader_path/../../../${PYTHON_PROJECT}/.libs")
elseif(UNIX)
set_target_properties(constraint_solver_pybind11 PROPERTIES
INSTALL_RPATH "$ORIGIN:$ORIGIN/../../../${PYTHON_PROJECT}/.libs"
)
INSTALL_RPATH "$ORIGIN:$ORIGIN/../../../${PYTHON_PROJECT}/.libs")
endif()

target_link_libraries(constraint_solver_pybind11 PRIVATE
${PROJECT_NAMESPACE}::ortools
pybind11_native_proto_caster
)
pybind11_native_proto_caster)
add_library(${PROJECT_NAMESPACE}::constraint_solver_pybind11 ALIAS constraint_solver_pybind11)

# legacy pywrapcp
Expand All @@ -58,8 +52,7 @@ if(APPLE)
set_target_properties(pywrapcp PROPERTIES
SUFFIX ".so"
INSTALL_RPATH "@loader_path;@loader_path/../../${PROJECT_NAME}/.libs")
set_property(TARGET pywrapcp APPEND PROPERTY
LINK_FLAGS "-flat_namespace -undefined suppress")
target_link_options(pywrapcp PRIVATE "LINKER:-undefined,dynamic_lookup")
elseif(UNIX)
set_target_properties(pywrapcp PROPERTIES
INSTALL_RPATH "$ORIGIN:$ORIGIN/../../${PROJECT_NAME}/.libs")
Expand Down
3 changes: 0 additions & 3 deletions ortools/graph/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ if(APPLE)
set_target_properties(linear_sum_assignment_pybind11 PROPERTIES
SUFFIX ".so"
INSTALL_RPATH "@loader_path;@loader_path/../../../${PYTHON_PROJECT}/.libs"
LINK_FLAGS "-flat_namespace -undefined suppress"
)
elseif(UNIX)
set_target_properties(linear_sum_assignment_pybind11 PROPERTIES
Expand All @@ -37,7 +36,6 @@ if(APPLE)
set_target_properties(max_flow_pybind11 PROPERTIES
SUFFIX ".so"
INSTALL_RPATH "@loader_path;@loader_path/../../../${PYTHON_PROJECT}/.libs"
LINK_FLAGS "-flat_namespace -undefined suppress"
)
elseif(UNIX)
set_target_properties(max_flow_pybind11 PROPERTIES
Expand All @@ -55,7 +53,6 @@ if(APPLE)
set_target_properties(min_cost_flow_pybind11 PROPERTIES
SUFFIX ".so"
INSTALL_RPATH "@loader_path;@loader_path/../../../${PYTHON_PROJECT}/.libs"
LINK_FLAGS "-flat_namespace -undefined suppress"
)
elseif(UNIX)
set_target_properties(min_cost_flow_pybind11 PROPERTIES
Expand Down
9 changes: 2 additions & 7 deletions ortools/init/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,10 @@ set_target_properties(init_pybind11 PROPERTIES
if(APPLE)
set_target_properties(init_pybind11 PROPERTIES
SUFFIX ".so"
INSTALL_RPATH "@loader_path;@loader_path/../../../${PYTHON_PROJECT}/.libs"
)
set_property(TARGET init_pybind11 APPEND PROPERTY
LINK_FLAGS "-flat_namespace -undefined suppress"
)
INSTALL_RPATH "@loader_path;@loader_path/../../../${PYTHON_PROJECT}/.libs")
elseif(UNIX)
set_target_properties(init_pybind11 PROPERTIES
INSTALL_RPATH "$ORIGIN:$ORIGIN/../../../${PYTHON_PROJECT}/.libs"
)
INSTALL_RPATH "$ORIGIN:$ORIGIN/../../../${PYTHON_PROJECT}/.libs")
endif()

target_link_libraries(init_pybind11 PRIVATE ${PROJECT_NAMESPACE}::ortools)
Expand Down
15 changes: 4 additions & 11 deletions ortools/linear_solver/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ if(APPLE)
set_target_properties(pywraplp PROPERTIES
SUFFIX ".so"
INSTALL_RPATH "@loader_path;@loader_path/../../${PROJECT_NAME}/.libs")
set_property(TARGET pywraplp APPEND PROPERTY
LINK_FLAGS "-flat_namespace -undefined suppress")
target_link_options(pywraplp PRIVATE "LINKER:-undefined,dynamic_lookup")
elseif(UNIX)
set_target_properties(pywraplp PROPERTIES
INSTALL_RPATH "$ORIGIN:$ORIGIN/../../${PROJECT_NAME}/.libs")
Expand All @@ -57,22 +56,16 @@ target_include_directories(model_builder_helper_pybind11 PRIVATE
if(APPLE)
set_target_properties(model_builder_helper_pybind11 PROPERTIES
SUFFIX ".so"
INSTALL_RPATH "@loader_path;@loader_path/../../../${PYTHON_PROJECT}/.libs"
)
set_property(TARGET model_builder_helper_pybind11 APPEND PROPERTY
LINK_FLAGS "-flat_namespace -undefined suppress"
)
INSTALL_RPATH "@loader_path;@loader_path/../../../${PYTHON_PROJECT}/.libs")
elseif(UNIX)
set_target_properties(model_builder_helper_pybind11 PROPERTIES
INSTALL_RPATH "$ORIGIN:$ORIGIN/../../../${PYTHON_PROJECT}/.libs"
)
INSTALL_RPATH "$ORIGIN:$ORIGIN/../../../${PYTHON_PROJECT}/.libs")
endif()

target_link_libraries(model_builder_helper_pybind11 PRIVATE
${PROJECT_NAMESPACE}::ortools
pybind11_native_proto_caster
Eigen3::Eigen
)
Eigen3::Eigen)
add_library(${PROJECT_NAMESPACE}::model_builder_helper_pybind11 ALIAS model_builder_helper_pybind11)

if(BUILD_TESTING)
Expand Down
12 changes: 3 additions & 9 deletions ortools/math_opt/core/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,19 @@ if(APPLE)
set_target_properties(math_opt_pybind11 PROPERTIES
SUFFIX ".so"
INSTALL_RPATH
"@loader_path;@loader_path/../../../../${PYTHON_PROJECT}/.libs;@loader_path/../../../../pybind11_abseil"
)
set_property(TARGET math_opt_pybind11 APPEND PROPERTY
LINK_FLAGS "-flat_namespace -undefined suppress"
)
"@loader_path;@loader_path/../../../../${PYTHON_PROJECT}/.libs;@loader_path/../../../../pybind11_abseil")
elseif(UNIX)
set_target_properties(math_opt_pybind11 PROPERTIES
INSTALL_RPATH
"$ORIGIN:$ORIGIN/../../../../${PYTHON_PROJECT}/.libs:$ORIGIN/../../../../pybind11_abseil"
)
"$ORIGIN:$ORIGIN/../../../../${PYTHON_PROJECT}/.libs:$ORIGIN/../../../../pybind11_abseil")
endif()

target_link_libraries(math_opt_pybind11 PRIVATE
${PROJECT_NAMESPACE}::ortools
pybind11_abseil::absl_casters
pybind11_abseil::status_casters
pybind11_native_proto_caster
protobuf::libprotobuf
)
protobuf::libprotobuf)
add_library(${PROJECT_NAMESPACE}::math_opt_pybind11 ALIAS math_opt_pybind11)

if(BUILD_TESTING)
Expand Down
10 changes: 3 additions & 7 deletions ortools/pdlp/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,15 @@ set_target_properties(pdlp_pybind11 PROPERTIES
if(APPLE)
set_target_properties(pdlp_pybind11 PROPERTIES
SUFFIX ".so"
INSTALL_RPATH "@loader_path;@loader_path/../../../${PYTHON_PROJECT}/.libs"
LINK_FLAGS "-flat_namespace -undefined suppress"
)
INSTALL_RPATH "@loader_path;@loader_path/../../../${PYTHON_PROJECT}/.libs")
elseif(UNIX)
set_target_properties(pdlp_pybind11 PROPERTIES
INSTALL_RPATH "$ORIGIN:$ORIGIN/../../../${PYTHON_PROJECT}/.libs"
)
INSTALL_RPATH "$ORIGIN:$ORIGIN/../../../${PYTHON_PROJECT}/.libs")
endif()
target_link_libraries(pdlp_pybind11 PRIVATE
${PROJECT_NAMESPACE}::ortools
pybind11_native_proto_caster
protobuf::libprotobuf
)
protobuf::libprotobuf)
target_include_directories(pdlp_pybind11 PRIVATE ${protobuf_SOURCE_DIR})
add_library(${PROJECT_NAMESPACE}::pdlp_pybind11 ALIAS pdlp_pybind11)

Expand Down
1 change: 0 additions & 1 deletion ortools/routing/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,3 @@ cc_library(
"@com_google_protobuf//:protobuf",
],
)

12 changes: 3 additions & 9 deletions ortools/routing/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,10 @@ set_target_properties(routing_pybind11 PROPERTIES
if(APPLE)
set_target_properties(routing_pybind11 PROPERTIES
SUFFIX ".so"
INSTALL_RPATH "@loader_path;@loader_path/../../../${PYTHON_PROJECT}/.libs"
)
set_property(TARGET routing_pybind11 APPEND PROPERTY
LINK_FLAGS "-flat_namespace -undefined suppress"
)
INSTALL_RPATH "@loader_path;@loader_path/../../../${PYTHON_PROJECT}/.libs")
elseif(UNIX)
set_target_properties(routing_pybind11 PROPERTIES
INSTALL_RPATH "$ORIGIN:$ORIGIN/../../../${PYTHON_PROJECT}/.libs"
)
INSTALL_RPATH "$ORIGIN:$ORIGIN/../../../${PYTHON_PROJECT}/.libs")
endif()

target_link_libraries(routing_pybind11 PRIVATE
Expand Down Expand Up @@ -58,8 +53,7 @@ if(APPLE)
set_target_properties(pywraprouting PROPERTIES
SUFFIX ".so"
INSTALL_RPATH "@loader_path;@loader_path/../../${PROJECT_NAME}/.libs")
set_property(TARGET pywraprouting APPEND PROPERTY
LINK_FLAGS "-flat_namespace -undefined suppress")
target_link_options(pywraprouting PRIVATE "LINKER:-undefined,dynamic_lookup")
elseif(UNIX)
set_target_properties(pywraprouting PROPERTIES
INSTALL_RPATH "$ORIGIN:$ORIGIN/../../${PROJECT_NAME}/.libs")
Expand Down
12 changes: 3 additions & 9 deletions ortools/sat/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,15 @@ set_target_properties(swig_helper_pybind11 PROPERTIES
if(APPLE)
set_target_properties(swig_helper_pybind11 PROPERTIES
SUFFIX ".so"
INSTALL_RPATH "@loader_path;@loader_path/../../../${PYTHON_PROJECT}/.libs"
)
set_property(TARGET swig_helper_pybind11 APPEND PROPERTY
LINK_FLAGS "-flat_namespace -undefined suppress"
)
INSTALL_RPATH "@loader_path;@loader_path/../../../${PYTHON_PROJECT}/.libs")
elseif(UNIX)
set_target_properties(swig_helper_pybind11 PROPERTIES
INSTALL_RPATH "$ORIGIN:$ORIGIN/../../../${PYTHON_PROJECT}/.libs"
)
INSTALL_RPATH "$ORIGIN:$ORIGIN/../../../${PYTHON_PROJECT}/.libs")
endif()
target_link_libraries(swig_helper_pybind11 PRIVATE
${PROJECT_NAMESPACE}::ortools
pybind11_native_proto_caster
protobuf::libprotobuf
)
protobuf::libprotobuf)

target_include_directories(swig_helper_pybind11 PRIVATE ${protobuf_SOURCE_DIR})
add_library(${PROJECT_NAMESPACE}::swig_helper_pybind11 ALIAS swig_helper_pybind11)
Expand Down
12 changes: 3 additions & 9 deletions ortools/scheduling/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,15 @@ set_target_properties(rcpsp_pybind11 PROPERTIES
if(APPLE)
set_target_properties(rcpsp_pybind11 PROPERTIES
SUFFIX ".so"
INSTALL_RPATH "@loader_path;@loader_path/../../../${PYTHON_PROJECT}/.libs"
)
set_property(TARGET rcpsp_pybind11 APPEND PROPERTY
LINK_FLAGS "-flat_namespace -undefined suppress"
)
INSTALL_RPATH "@loader_path;@loader_path/../../../${PYTHON_PROJECT}/.libs")
elseif(UNIX)
set_target_properties(rcpsp_pybind11 PROPERTIES
INSTALL_RPATH "$ORIGIN:$ORIGIN/../../../${PYTHON_PROJECT}/.libs"
)
INSTALL_RPATH "$ORIGIN:$ORIGIN/../../../${PYTHON_PROJECT}/.libs")
endif()
target_link_libraries(rcpsp_pybind11 PRIVATE
${PROJECT_NAMESPACE}::ortools
pybind11_native_proto_caster
protobuf::libprotobuf
)
protobuf::libprotobuf)

target_include_directories(rcpsp_pybind11 PRIVATE ${protobuf_SOURCE_DIR})
add_library(${PROJECT_NAMESPACE}::rcpsp_pybind11 ALIAS rcpsp_pybind11)
Expand Down
9 changes: 2 additions & 7 deletions ortools/util/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,10 @@ set_target_properties(sorted_interval_list_pybind11 PROPERTIES
if(APPLE)
set_target_properties(sorted_interval_list_pybind11 PROPERTIES
SUFFIX ".so"
INSTALL_RPATH "@loader_path;@loader_path/../../../${PYTHON_PROJECT}/.libs"
)
set_property(TARGET sorted_interval_list_pybind11 APPEND PROPERTY
LINK_FLAGS "-flat_namespace -undefined suppress"
)
INSTALL_RPATH "@loader_path;@loader_path/../../../${PYTHON_PROJECT}/.libs")
elseif(UNIX)
set_target_properties(sorted_interval_list_pybind11 PROPERTIES
INSTALL_RPATH "$ORIGIN:$ORIGIN/../../../${PYTHON_PROJECT}/.libs"
)
INSTALL_RPATH "$ORIGIN:$ORIGIN/../../../${PYTHON_PROJECT}/.libs")
endif()

target_link_libraries(sorted_interval_list_pybind11 PRIVATE ${PROJECT_NAMESPACE}::ortools)
Expand Down

0 comments on commit 1da3f34

Please sign in to comment.