@@ -46,6 +46,18 @@ execute_process(
4646)
4747add_definitions ("-DGIT_COMMIT_HASH=\" ${GIT_COMMIT_HASH} \" " )
4848
49+ ############################
50+ ## Conda env detection ##
51+ ############################
52+
53+ if (DEFINED ENV{CONDA_PREFIX} AND NOT DEFINED ENV{CONDA_BUILD})
54+ list (INSERT CMAKE_PREFIX_PATH 0 "$ENV{CONDA_PREFIX} " )
55+ message (STATUS "Conda environment detected: $ENV{CONDA_PREFIX} " )
56+ elseif (DEFINED ENV{CONDA_BUILD})
57+ list (INSERT CMAKE_PREFIX_PATH 0 "$ENV{PREFIX} " "$ENV{BUILD_PREFIX} " )
58+ message (STATUS "Conda build environment detected" )
59+ endif ()
60+
4961#########################
5062## Basic configuration ##
5163#########################
@@ -80,56 +92,17 @@ include_directories(SYSTEM ${CVC4_DIR} ${CVC4_DIR}/include)
8092## Boost ##
8193###########
8294
83- # Avoid using deprecated operations
8495add_definitions (-DBOOST_NO_CXX98_FUNCTION_BASE )
85- set (BOOST_VERSION 1.84.0)
86- set (BOOST_DIR "${TOOLS_DIR} /boost-${BOOST_VERSION} " )
87- if (MSVC )
88- set (BOOST_ROOT "${BOOST_DIR} /win_installed" )
89- set (Boost_NAMESPACE libboost)
90- elseif (${CMAKE_SIZEOF_VOID_P } EQUAL 4 AND NOT MSVC )
91- set (BOOST_ROOT "${BOOST_DIR} /installed32" )
92- else ()
93- set (BOOST_ROOT "${BOOST_DIR} /installed" )
94- endif ()
95-
96- set (Boost_USE_DEBUG_RUNTIME FALSE )
97- find_package (Boost ${BOOST_VERSION} COMPONENTS program_options timer chrono thread )
98- # Find boost
99- if (NOT ${Boost_FOUND} )
100- execute_process (COMMAND ${TOOLS_DIR} /download_boost.${SCRIPT_EXTENSION} ${BOOST_VERSION} )
101- find_package (Boost ${BOOST_VERSION} REQUIRED COMPONENTS program_options timer chrono thread regex )
102- endif ()
96+ find_package (Boost 1.84.0 REQUIRED COMPONENTS program_options timer chrono thread )
10397set (LIBS_INCLUDES ${Boost_INCLUDE_DIRS} )
10498list (APPEND LIBS ${Boost_LIBRARIES} )
10599
106100##############
107101## Protobuf ##
108102##############
109- # Protobuf is needed to compile ONNX
110103
111- set (PROTOBUF_VERSION 3.19.2)
112- set (PROTOBUF_DEFAULT_DIR "${TOOLS_DIR} /protobuf-${PROTOBUF_VERSION} " )
113- if (NOT PROTOBUF_DIR)
114- set (PROTOBUF_DIR ${PROTOBUF_DEFAULT_DIR} )
115- endif ()
116-
117- if (NOT EXISTS "${PROTOBUF_DIR} /installed/lib/libprotobuf.a" )
118- message ("Can't find protobuf, installing. If protobuf is installed please use the PROTOBUF_DIR parameter to pass the path" )
119- if (${PROTOBUF_DIR} STREQUAL ${PROTOBUF_DEFAULT_DIR} )
120- message ("installing protobuf" )
121- execute_process (COMMAND ${TOOLS_DIR} /download_protobuf.sh ${PROTOBUF_VERSION} )
122- else ()
123- message (FATAL_ERROR "Can't find protobuf in the supplied directory" )
124- endif ()
125- endif ()
126-
127- set (PROTOBUF_LIB protobuf)
128- add_library (${PROTOBUF_LIB} SHARED IMPORTED )
129- set_property (TARGET ${PROTOBUF_LIB} PROPERTY POSITION_INDEPENDENT_CODE ON )
130- set_target_properties (${PROTOBUF_LIB} PROPERTIES IMPORTED_LOCATION ${PROTOBUF_DIR} /installed/lib/libprotobuf.a)
131- target_include_directories (${PROTOBUF_LIB} INTERFACE ${PROTOBUF_DIR} /installed/include )
132- list (APPEND LIBS ${PROTOBUF_LIB} )
104+ find_package (Protobuf 3.19.2 REQUIRED )
105+ list (APPEND LIBS protobuf::libprotobuf)
133106
134107##########
135108## ONNX ##
@@ -141,7 +114,7 @@ set(ONNX_DIR "${TOOLS_DIR}/onnx-${ONNX_VERSION}")
141114
142115if (NOT EXISTS "${ONNX_DIR} /onnx.proto3.pb.h" )
143116 message ("generating ONNX protobuf file" )
144- execute_process (COMMAND ${TOOLS_DIR} /download_onnx.sh ${ONNX_VERSION} ${PROTOBUF_VERSION } )
117+ execute_process (COMMAND ${TOOLS_DIR} /download_onnx.sh ${ONNX_VERSION} ${Protobuf_PROTOC_EXECUTABLE } )
145118endif ()
146119file (GLOB DEPS_ONNX "${ONNX_DIR} /*.cc" )
147120include_directories (SYSTEM ${ONNX_DIR} )
@@ -183,30 +156,15 @@ endif()
183156##############
184157
185158if (NOT MSVC AND ${ENABLE_OPENBLAS} )
186- set (OPENBLAS_VERSION 0.3.19)
187-
188- set (OPENBLAS_LIB openblas)
189- set (OPENBLAS_DEFAULT_DIR "${TOOLS_DIR} /OpenBLAS-${OPENBLAS_VERSION} " )
190- if (NOT OPENBLAS_DIR)
191- set (OPENBLAS_DIR ${OPENBLAS_DEFAULT_DIR} )
192- endif ()
193-
194159 message (STATUS "Using OpenBLAS for matrix multiplication" )
195160 add_compile_definitions (ENABLE_OPENBLAS )
196- if (NOT EXISTS "${OPENBLAS_DIR} /installed/lib/libopenblas.a" )
197- message ("Can't find OpenBLAS, installing. If OpenBLAS is installed please use the OPENBLAS_DIR parameter to pass the path" )
198- if (${OPENBLAS_DIR} STREQUAL ${OPENBLAS_DEFAULT_DIR} )
199- message ("Installing OpenBLAS" )
200- execute_process (COMMAND ${TOOLS_DIR} /download_openBLAS.sh ${OPENBLAS_VERSION} )
201- else ()
202- message (FATAL_ERROR "Can't find OpenBLAS in the supplied directory" )
203- endif ()
161+ find_library (OPENBLAS_LIB openblas REQUIRED )
162+ find_path (OPENBLAS_INCLUDE_DIR openblas_config.h PATH_SUFFIXES openblas )
163+ if (NOT OPENBLAS_INCLUDE_DIR)
164+ message (FATAL_ERROR "Could not find OpenBLAS headers (openblas_config.h)" )
204165 endif ()
205-
206- add_library (${OPENBLAS_LIB} SHARED IMPORTED )
207- set_target_properties (${OPENBLAS_LIB} PROPERTIES IMPORTED_LOCATION ${OPENBLAS_DIR} /installed/lib/libopenblas.a)
208166 list (APPEND LIBS ${OPENBLAS_LIB} )
209- target_include_directories ( ${OPENBLAS_LIB} INTERFACE ${OPENBLAS_DIR} /installed/include )
167+ list ( APPEND LIBS_INCLUDES ${OPENBLAS_INCLUDE_DIR} )
210168endif ()
211169
212170###########
@@ -370,9 +328,6 @@ endif()
370328
371329# Actually build Python
372330if (${BUILD_PYTHON} )
373- set (PYBIND11_VERSION 2.13.6)
374- set (PYBIND11_DIR "${TOOLS_DIR} /pybind11-${PYBIND11_VERSION} " )
375-
376331 # This is suppose to set the PYTHON_EXECUTABLE variable
377332 # First try to find the default python version
378333 find_package (PythonInterp ${DEFAULT_PYTHON_VERSION} )
@@ -381,11 +336,7 @@ if (${BUILD_PYTHON})
381336 find_package (PythonInterp REQUIRED )
382337 endif ()
383338
384- if (NOT EXISTS ${PYBIND11_DIR} )
385- message ("didnt find pybind, getting it" )
386- execute_process (COMMAND ${TOOLS_DIR} /download_pybind11.${SCRIPT_EXTENSION} ${PYBIND11_VERSION} )
387- endif ()
388- add_subdirectory (${PYBIND11_DIR} )
339+ find_package (pybind11 REQUIRED )
389340
390341 set (MARABOU_PY MarabouCore)
391342 pybind11_add_module (${MARABOU_PY} ${PYTHON_API_DIR} /MarabouCore.cpp )
@@ -479,6 +430,6 @@ add_custom_target(build_input_parsers)
479430add_dependencies (build_input_parsers ${MPS_PARSER} ${ACAS_PARSER}
480431 ${BERKELEY_PARSER} )
481432
482- add_subdirectory (${SRC_DIR} )
483433add_subdirectory (${TOOLS_DIR} )
434+ add_subdirectory (${SRC_DIR} )
484435add_subdirectory (${REGRESS_DIR} )
0 commit comments