CMakeLists.txt 17.3 KB
Newer Older
Dominik Bongartz's avatar
Dominik Bongartz committed
1
cmake_minimum_required(VERSION 3.15)
Dominik Bongartz's avatar
Dominik Bongartz committed
2

Dominik Bongartz's avatar
Dominik Bongartz committed
3
4
5
6
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/MAiNGOversion.cmake)
project(MAiNGO
    VERSION ${MAiNGO_VERSION}
    LANGUAGES CXX)
Dominik Bongartz's avatar
Dominik Bongartz committed
7

Dominik Bongartz's avatar
Dominik Bongartz committed
8

Dominik Bongartz's avatar
Dominik Bongartz committed
9
10
#--------------------------- Settings --------------------------------
set(MAiNGO_use_melon TRUE CACHE BOOL "Build MAiNGO executable with the MeLOn toolbox.")
Dominik Bongartz's avatar
Dominik Bongartz committed
11
12
13
set(MAiNGO_use_cplex TRUE CACHE BOOL "Use CPLEX if it is available on the system.")
set(MAiNGO_use_knitro TRUE CACHE BOOL "Use KNITRO if it is available on the system.")
set(MAiNGO_use_mpi FALSE CACHE BOOL "Build parallel version of MAiNGO.")
Dominik Bongartz's avatar
Dominik Bongartz committed
14
15
16
17
18
19
20
21
22
set(MAiNGO_build_python_interface FALSE CACHE BOOL "Build the Python package 'maingopy' that allows to call MAiNGO from Python.")
set(MAiNGO_build_standalone FALSE CACHE BOOL "Build MAiNGOcpp executable as standalone solver with problem.h.")
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
    set(MAiNGO_build_parser TRUE CACHE BOOL "Build MAiNGO executable with parser.")
    set(MAiNGO_build_test TRUE CACHE BOOL "Build MAiNGO test cases.")
else()
    set(MAiNGO_build_parser FALSE CACHE BOOL "Build MAiNGO executable with parser.")
    set(MAiNGO_build_test FALSE CACHE BOOL "Build MAiNGO test cases.")
endif()
Dominik Bongartz's avatar
Dominik Bongartz committed
23
24


Dominik Bongartz's avatar
Dominik Bongartz committed
25
#------------------------ Adjust settings when building with scikit-build -----------------------------
Dominik Bongartz's avatar
Dominik Bongartz committed
26
27
if(SKBUILD)
    message(STATUS "The project is built using scikit-build, also building Python interface.")
Dominik Bongartz's avatar
Dominik Bongartz committed
28
    # Enforce use of Python interface
Dominik Bongartz's avatar
Dominik Bongartz committed
29
    set(MAiNGO_build_python_interface TRUE CACHE INTERNAL "" FORCE)
Dominik Bongartz's avatar
Dominik Bongartz committed
30
31
32
33
34
    # Default: disable use of CPLEX and KNITRO
    message(STATUS "Not using CPLEX and KNITRO even if they are available. If you still want to use them, you need to explicitly enable the corresponding CMake options.")
    set(MAiNGO_use_cplex FALSE CACHE BOOL "Use CPLEX if it is available on the system." FORCE)
    set(MAiNGO_use_knitro FALSE CACHE BOOL "Use KNITRO if it is available on the system." FORCE)
    # Disable stuff that is not compatible with the Python package to be installed
Dominik Bongartz's avatar
Dominik Bongartz committed
35
36
37
    set(MAiNGO_use_mpi FALSE CACHE INTERNAL "" FORCE)
    set(MAiNGO_build_standalone FALSE CACHE INTERNAL "" FORCE)
    set(MAiNGO_build_parser FALSE CACHE INTERNAL "" FORCE)
Dominik Bongartz's avatar
Dominik Bongartz committed
38
    set(MAiNGO_build_test FALSE CACHE INTERNAL "" FORCE)
Dominik Bongartz's avatar
Dominik Bongartz committed
39
40
41
    set(BLAS_usePrecompiledDll FALSE CACHE INTERNAL "" FORCE)
    set(LAPACK_usePrecompiledDlls FALSE CACHE INTERNAL "" FORCE)
    set(MUMPS_usePrecompiledDll FALSE CACHE INTERNAL "" FORCE)
Dominik Bongartz's avatar
Dominik Bongartz committed
42
43
44
    # Force required settings
    set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
    set(BUILD_SHARED_LIBS FALSE CACHE INTERNAL "" FORCE)
Dominik Bongartz's avatar
Dominik Bongartz committed
45
endif()
Dominik Bongartz's avatar
Dominik Bongartz committed
46
47
48
if(MAiNGO_build_python_interface)
    # if building the python interface, the generated module needs PIC, even if building static libraries
    set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Dominik Bongartz's avatar
Dominik Bongartz committed
49
endif()
Dominik Bongartz's avatar
Dominik Bongartz committed
50
51
52
53


#------------------------ MAiNGO library -----------------------------
include(${PROJECT_SOURCE_DIR}/cmake/MAiNGOsourceFiles.cmake)
Dominik Bongartz's avatar
Dominik Bongartz committed
54
55
56
add_library(maingo-core ${MAiNGO_SRC})
if(WIN32 AND BUILD_SHARED_LIBS)
    set_target_properties(maingo-core PRIVATE WINDOWS_EXPORT_ALL_SYMBOLS ON)
Dominik Bongartz's avatar
Dominik Bongartz committed
57
58
endif()

Dominik Bongartz's avatar
Dominik Bongartz committed
59
60
61
62
63
64
65
66
configure_file(${PROJECT_SOURCE_DIR}/inc/version.h.in maingo-core/version.h)
target_include_directories(maingo-core
    PUBLIC
        ${PROJECT_SOURCE_DIR}/inc
    PRIVATE
        ${CMAKE_CURRENT_BINARY_DIR}/maingo-core
    )

Dominik Bongartz's avatar
Dominik Bongartz committed
67
68
69
70
target_compile_features(maingo-core PRIVATE cxx_std_14)
if(MSVC)
    target_compile_options(maingo-core PRIVATE /MP;/Qpar)
else()
Dominik Bongartz's avatar
Dominik Bongartz committed
71
72
73
74
75
76
    target_compile_options(maingo-core
        PRIVATE
            $<$<CXX_COMPILER_ID:Intel>: $<$<NOT:$<CONFIG:DEBUG>>:-O3> $<$<CONFIG:DEBUG>:-O0>>
            $<$<CXX_COMPILER_ID:GNU>: $<$<NOT:$<CONFIG:DEBUG>>:-O3> $<$<CONFIG:DEBUG>:-O0>>
            $<$<CXX_COMPILER_ID:AppleClang>: $<$<NOT:$<CONFIG:DEBUG>>:-O3> $<$<CONFIG:DEBUG>:-O0>>
            $<$<CXX_COMPILER_ID:Clang>: $<$<NOT:$<CONFIG:DEBUG>>:-O3> $<$<CONFIG:DEBUG>:-O0>>
Dominik Bongartz's avatar
Dominik Bongartz committed
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
        )
endif()

if(MAiNGO_use_cplex)
    # cplex has to be linked first, since on Linux/MacOS, it comes as a static library that contains BLAS etc.
    # if linking it after our blas, this will result in multiply defined symbols
    target_link_libraries(maingo-core PRIVATE cplex-ilo cplex-concert cplex-lib)
endif()
target_link_libraries(maingo-core
    PUBLIC
        babbase
        mcpp
    PRIVATE
        filib
        mumps
        nlopt
        ipopt
        clp
Dominik Bongartz's avatar
Dominik Bongartz committed
95
96
    )
if(MAiNGO_build_parser)
Dominik Bongartz's avatar
Dominik Bongartz committed
97
98
99
100
101
102
103
    add_library(parser STATIC ${PARSER_SRC})
    target_include_directories(parser PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/inc)
    target_link_libraries(parser PUBLIC ale babbase mcpp)
    target_compile_features(parser PRIVATE cxx_std_17)
    target_link_libraries(maingo-core PUBLIC parser)
    target_compile_definitions(maingo-core PUBLIC HAVE_MAiNGO_PARSER)
endif()
Dominik Bongartz's avatar
Dominik Bongartz committed
104
105
106
if(MAiNGO_use_melon)
    target_link_libraries(maingo-core PUBLIC melon)
endif()
Dominik Bongartz's avatar
Dominik Bongartz committed
107
108
109
if(MAiNGO_use_knitro)
    # knitro always needs to be linked after all other math-related libraries because of incompatibility with several math routines
    target_link_libraries(maingo-core PRIVATE knitro)
Dominik Bongartz's avatar
Dominik Bongartz committed
110
111
endif()
if(MAiNGO_use_mpi)
Dominik Bongartz's avatar
Dominik Bongartz committed
112
113
114
115
    find_package(MPI REQUIRED QUIET)
    message("Found MPI. Run MAiNGO with MPI like this: ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} <yourMAiNGOexecutable> ${MPIEXEC_POSTFLAGS} <yourCommandLineArguments>")
    target_compile_definitions(maingo-core PUBLIC HAVE_MAiNGO_MPI) # Define pre-processor variable HAVE_MAiNGO_MPI
    target_link_libraries(maingo-core PUBLIC MPI::MPI_CXX)
Dominik Bongartz's avatar
Dominik Bongartz committed
116
117
118
endif()


Dominik Bongartz's avatar
Dominik Bongartz committed
119
#----------------- If this is the top level, include dependencies  --------------------
Dominik Bongartz's avatar
Dominik Bongartz committed
120
121
122
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)

    # --------------- Dependencies ---------------------------
Dominik Bongartz's avatar
Dominik Bongartz committed
123
124
125
126
127
    message("=================================================================")
    message("=================================================================")
    message("Configure dependencies...")
    message("=================================================================")
    include(${PROJECT_SOURCE_DIR}/cmake/addDependency.cmake)
Dominik Bongartz's avatar
Dominik Bongartz committed
128
129
130
131
132
133
134
135
136
137
    add_dependency_subdir(babbase)
    add_dependency_subdir(fadbad)
    add_dependency_subdir(blas)
    add_dependency_subdir(lapack)
    add_dependency_subdir(cpplapack)
    add_dependency_subdir(mcpp)
    add_dependency_subdir(mumps)
    add_dependency_subdir(ipopt)
    add_dependency_subdir(nlopt)
    add_dependency_subdir(clp)
Dominik Bongartz's avatar
Dominik Bongartz committed
138
    add_dependency_subdir(filib)
Dominik Bongartz's avatar
Dominik Bongartz committed
139
    if(MAiNGO_build_parser)
Dominik Bongartz's avatar
Dominik Bongartz committed
140
        add_dependency_subdir(libale)
Dominik Bongartz's avatar
Dominik Bongartz committed
141
    endif()
Dominik Bongartz's avatar
Dominik Bongartz committed
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
    if(MAiNGO_use_cplex)
        add_dependency_subdir(cplex)
    endif()
    if(MAiNGO_use_knitro)
        add_dependency_subdir(knitro)
    endif()
    if(MAiNGO_build_python_interface)
        set(PYBIND11_FINDPYTHON FALSE CACHE BOOL "Whether to have pybind11 use FindPython")
        if(SKBUILD)
            set(Python_EXECUTABLE ${PYTHON_EXECUTABLE})
            set(Python_VERSION ${PYTHON_VERSION_STRING})
            set(Python_INCLUDE_DIRS ${PYTHON_INCLUDE_DIR})
            set(Python_LIBRARIES ${PYTHON_LIBRARY})
        endif()
        add_dependency_subdir(pybind11)
    endif()
Dominik Bongartz's avatar
Dominik Bongartz committed
158
159
160
161
162
163
164
    if(MAiNGO_use_melon) # Melon needs to go after pybind11, since it's CMakeLists.txt need pybind11_add_module if using the Python interface of MeLOn
        if(MAiNGO_build_python_interface)
            set(MeLOn_build_python_interface TRUE CACHE BOOL "" FORCE)
        endif()
        add_dependency_subdir(melon)
        add_dependency_subdir(json)
    endif()
Dominik Bongartz's avatar
Dominik Bongartz committed
165
166
167
168
169
170
171
    message("Done configuring dependencies.")
    message("=================================================================")
    message("=================================================================")

    if( (NOT BLAS_usePrecompiledDll) OR (NOT LAPACK_usePrecompiledDlls) OR (NOT MUMPS_usePrecompiledDll) )
        enable_language(Fortran)
    endif()
Dominik Bongartz's avatar
Dominik Bongartz committed
172
173
174
175

    # --------- Setup the Executable/.dll output Directory -------------
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} CACHE PATH "Single Directory for all Executables.")

Dominik Bongartz's avatar
Dominik Bongartz committed
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
endif()



# --------------- MAiNGO executable (using ALE parser) ---------------------------
if (MAiNGO_build_parser)

    add_executable(MAiNGO ${PROJECT_SOURCE_DIR}/examples/mainAleParser.cpp)
    target_link_libraries(MAiNGO PRIVATE maingo-core)
    target_compile_features(MAiNGO PRIVATE cxx_std_17)
    if(MSVC)
        target_compile_options(MAiNGO PRIVATE /MP;/Qpar)
        set_target_properties(MAiNGO PROPERTIES LINK_FLAGS /ignore:4099) #/ignore:4099 disables annoying linker warning because cplex does not provide debugging information
    else()
        target_compile_options(MAiNGO
            PRIVATE
                $<$<CXX_COMPILER_ID:Intel>: $<$<NOT:$<CONFIG:DEBUG>>:-O3> $<$<CONFIG:DEBUG>:-O0>>
                $<$<CXX_COMPILER_ID:GNU>: $<$<NOT:$<CONFIG:DEBUG>>:-O3> $<$<CONFIG:DEBUG>:-O0>>
                $<$<CXX_COMPILER_ID:AppleClang>: $<$<NOT:$<CONFIG:DEBUG>>:-O3> $<$<CONFIG:DEBUG>:-O0>>
                $<$<CXX_COMPILER_ID:Clang>: $<$<NOT:$<CONFIG:DEBUG>>:-O3> $<$<CONFIG:DEBUG>:-O0>>
            )
Dominik Bongartz's avatar
Dominik Bongartz committed
197
    endif()
Dominik Bongartz's avatar
Dominik Bongartz committed
198

Dominik Bongartz's avatar
Dominik Bongartz committed
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
endif()

# --------------- Standalone MAiNGO executable (for C++ API) ---------------------------
if (MAiNGO_build_standalone)

    add_executable(MAiNGOcpp ${PROJECT_SOURCE_DIR}/examples/mainCppApi.cpp)
    target_link_libraries(MAiNGOcpp PRIVATE maingo-core)
    target_compile_features(MAiNGOcpp PRIVATE cxx_std_14)
    if(MSVC)
        target_compile_options(MAiNGOcpp PRIVATE /MP;/Qpar)
        set_target_properties(MAiNGOcpp PROPERTIES LINK_FLAGS /ignore:4099) #/ignore:4099 disables annoying linker warning because cplex does not provide debugging information
    else()
        target_compile_options(MAiNGOcpp
            PRIVATE
                $<$<CXX_COMPILER_ID:Intel>: $<$<NOT:$<CONFIG:DEBUG>>:-O3> $<$<CONFIG:DEBUG>:-O0>>
                $<$<CXX_COMPILER_ID:GNU>: $<$<NOT:$<CONFIG:DEBUG>>:-O3> $<$<CONFIG:DEBUG>:-O0>>
                $<$<CXX_COMPILER_ID:AppleClang>: $<$<NOT:$<CONFIG:DEBUG>>:-O3> $<$<CONFIG:DEBUG>:-O0>>
                $<$<CXX_COMPILER_ID:Clang>: $<$<NOT:$<CONFIG:DEBUG>>:-O3> $<$<CONFIG:DEBUG>:-O0>>
            )
Dominik Bongartz's avatar
Dominik Bongartz committed
218
    endif()
Dominik Bongartz's avatar
Dominik Bongartz committed
219

Dominik Bongartz's avatar
Dominik Bongartz committed
220
221
222
223
224
225
226
227
228
229
230
231
endif()

# --------------- Python interface ---------------------------
if(MAiNGO_build_python_interface)

    # Get output directories right
    if(MSVC)
        set(RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/Debug)
        set(RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/Release)
    else()
        set(RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR})
        set(RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
Dominik Bongartz's avatar
Dominik Bongartz committed
232
233
    endif()

Dominik Bongartz's avatar
Dominik Bongartz committed
234
235
236
237
238
    # Create target for _maingopy extension module
    pybind11_add_module(_maingopy maingopy/_maingopy.cpp)
    target_compile_features(_maingopy PRIVATE cxx_std_14)
    target_link_libraries(_maingopy PRIVATE maingo-core)
    target_compile_options(_maingopy PRIVATE $<$<CXX_COMPILER_ID:AppleClang>: -fvisibility=default>)
Dominik Bongartz's avatar
Dominik Bongartz committed
239

Dominik Bongartz's avatar
Dominik Bongartz committed
240
241
242
243
244
245
246
    # Create target for maingopy package
    if(SKBUILD)
        install(TARGETS maingo-core DESTINATION . )
        install(TARGETS _maingopy DESTINATION .)
        if(MAiNGO_use_melon AND MeLOn_build_python_interface)
            install(TARGETS melonpy DESTINATION .)
            install(FILES ${PROJECT_SOURCE_DIR}/maingopy/__init__maingopy_and_melonpy.py.in DESTINATION . RENAME __init__.py)
Dominik Bongartz's avatar
Dominik Bongartz committed
247
        else()
Dominik Bongartz's avatar
Dominik Bongartz committed
248
        endif()
Dominik Bongartz's avatar
Dominik Bongartz committed
249
250
251
252
253
254
255
256
257
258
259
    else()
        set_target_properties(_maingopy PROPERTIES
            LIBRARY_OUTPUT_DIRECTORY $<$<CONFIG:Debug>:${RUNTIME_OUTPUT_DIRECTORY_DEBUG}>$<$<NOT:$<CONFIG:Debug>>:${RUNTIME_OUTPUT_DIRECTORY_RELEASE}>/maingopy
            ARCHIVE_OUTPUT_DIRECTORY $<$<CONFIG:Debug>:${RUNTIME_OUTPUT_DIRECTORY_DEBUG}>$<$<NOT:$<CONFIG:Debug>>:${RUNTIME_OUTPUT_DIRECTORY_RELEASE}>/maingopy
            )
        if(MAiNGO_use_melon AND MeLOn_build_python_interface)
            set_target_properties(melonpy PROPERTIES
                LIBRARY_OUTPUT_DIRECTORY $<$<CONFIG:Debug>:${RUNTIME_OUTPUT_DIRECTORY_DEBUG}>$<$<NOT:$<CONFIG:Debug>>:${RUNTIME_OUTPUT_DIRECTORY_RELEASE}>/maingopy
                ARCHIVE_OUTPUT_DIRECTORY $<$<CONFIG:Debug>:${RUNTIME_OUTPUT_DIRECTORY_DEBUG}>$<$<NOT:$<CONFIG:Debug>>:${RUNTIME_OUTPUT_DIRECTORY_RELEASE}>/maingopy
                )               
            add_custom_target(maingopy ALL
Dominik Bongartz's avatar
Dominik Bongartz committed
260
                COMMAND ${CMAKE_COMMAND} -E make_directory
Dominik Bongartz's avatar
Dominik Bongartz committed
261
                    $<$<CONFIG:Debug>:${RUNTIME_OUTPUT_DIRECTORY_DEBUG}>$<$<NOT:$<CONFIG:Debug>>:${RUNTIME_OUTPUT_DIRECTORY_RELEASE}>/maingopy
Dominik Bongartz's avatar
Dominik Bongartz committed
262
                COMMAND ${CMAKE_COMMAND} -E copy
Dominik Bongartz's avatar
Dominik Bongartz committed
263
264
265
266
267
268
269
270
271
                    ${PROJECT_SOURCE_DIR}/maingopy/__init__maingopy_and_melonpy.py.in
                    $<$<CONFIG:Debug>:${RUNTIME_OUTPUT_DIRECTORY_DEBUG}>$<$<NOT:$<CONFIG:Debug>>:${RUNTIME_OUTPUT_DIRECTORY_RELEASE}>/maingopy/__init__.py
                )
            add_dependencies(melonpy maingopy)
            add_dependencies(_maingopy maingopy)
        else()             
            add_custom_target(maingopy ALL
                COMMAND ${CMAKE_COMMAND} -E make_directory
                    $<$<CONFIG:Debug>:${RUNTIME_OUTPUT_DIRECTORY_DEBUG}>$<$<NOT:$<CONFIG:Debug>>:${RUNTIME_OUTPUT_DIRECTORY_RELEASE}>/maingopy
Dominik Bongartz's avatar
Dominik Bongartz committed
272
                COMMAND ${CMAKE_COMMAND} -E copy
Dominik Bongartz's avatar
Dominik Bongartz committed
273
274
                    ${PROJECT_SOURCE_DIR}/maingopy/__init__only_maingopy.py.in
                    $<$<CONFIG:Debug>:${RUNTIME_OUTPUT_DIRECTORY_DEBUG}>$<$<NOT:$<CONFIG:Debug>>:${RUNTIME_OUTPUT_DIRECTORY_RELEASE}>/maingopy/__init__.py
Dominik Bongartz's avatar
Dominik Bongartz committed
275
                )
Dominik Bongartz's avatar
Dominik Bongartz committed
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
            add_dependencies(_maingopy maingopy)
        endif()    
        if(${BLAS_usePrecompiledDll})
            add_custom_target(copyBlasDllmaingopy ALL
                COMMAND ${CMAKE_COMMAND} -E copy
                    $<$<CONFIG:Debug>:${RUNTIME_OUTPUT_DIRECTORY_DEBUG}/blasd.dll>$<$<NOT:$<CONFIG:Debug>>:${RUNTIME_OUTPUT_DIRECTORY_RELEASE}/blas.dll>
                    $<$<CONFIG:Debug>:${RUNTIME_OUTPUT_DIRECTORY_DEBUG}/maingopy/blasd.dll>$<$<NOT:$<CONFIG:Debug>>:${RUNTIME_OUTPUT_DIRECTORY_RELEASE}/maingopy/blas.dll>)
            add_dependencies(copyBlasDllmaingopy copyBlasDll melonpy)
        endif()
        if(${LAPACK_usePrecompiledDlls})
            add_custom_target(copyLapackDllmaingopy ALL
                COMMAND ${CMAKE_COMMAND} -E copy
                    $<$<CONFIG:Debug>:${RUNTIME_OUTPUT_DIRECTORY_DEBUG}/lapackd.dll>$<$<NOT:$<CONFIG:Debug>>:${RUNTIME_OUTPUT_DIRECTORY_RELEASE}/lapack.dll>
                    $<$<CONFIG:Debug>:${RUNTIME_OUTPUT_DIRECTORY_DEBUG}/maingopy/lapackd.dll>$<$<NOT:$<CONFIG:Debug>>:${RUNTIME_OUTPUT_DIRECTORY_RELEASE}/maingopy/lapack.dll>)
            add_dependencies(copyLapackDllmaingopy copyLapackDll melonpy)
        endif()
        if(${MUMPS_usePrecompiledDll})
            add_custom_target(copyMumpsDllmaingopy ALL
                COMMAND ${CMAKE_COMMAND} -E copy
                    $<$<CONFIG:Debug>:${RUNTIME_OUTPUT_DIRECTORY_DEBUG}/mumpsd.dll>$<$<NOT:$<CONFIG:Debug>>:${RUNTIME_OUTPUT_DIRECTORY_RELEASE}/mumps.dll>
                    $<$<CONFIG:Debug>:${RUNTIME_OUTPUT_DIRECTORY_DEBUG}/maingopy/mumpsd.dll>$<$<NOT:$<CONFIG:Debug>>:${RUNTIME_OUTPUT_DIRECTORY_RELEASE}/maingopy/mumps.dll>)
            add_dependencies(copyMumpsDllmaingopy copyMumpsDll melonpy)
Dominik Bongartz's avatar
Dominik Bongartz committed
298
        endif()
Dominik Bongartz's avatar
Dominik Bongartz committed
299
300
    endif()

Dominik Bongartz's avatar
Dominik Bongartz committed
301
endif()
Dominik Bongartz's avatar
Dominik Bongartz committed
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345


# --------------- MAiNGO Tests ---------------------------
if(MAiNGO_build_test)

    add_executable(test-maingo ${PROJECT_SOURCE_DIR}/tests/testProblems/main.cpp)
    target_link_libraries(test-maingo PRIVATE maingo-core)
    target_compile_features(test-maingo PRIVATE cxx_std_17)
    if(MSVC)
        target_compile_options(test-maingo PRIVATE /MP;/Qpar)
        set_target_properties(test-maingo PROPERTIES LINK_FLAGS /ignore:4099) #/ignore:4099 disables annoying linker warning because cplex does not provide debugging information
    else()
        target_compile_options(test-maingo
            PRIVATE
                $<$<CXX_COMPILER_ID:Intel>: $<$<NOT:$<CONFIG:DEBUG>>:-O3> $<$<CONFIG:DEBUG>:-O0>>
                $<$<CXX_COMPILER_ID:GNU>: $<$<NOT:$<CONFIG:DEBUG>>:-O3> $<$<CONFIG:DEBUG>:-O0>>
                $<$<CXX_COMPILER_ID:AppleClang>: $<$<NOT:$<CONFIG:DEBUG>>:-O3> $<$<CONFIG:DEBUG>:-O0>>
                $<$<CXX_COMPILER_ID:Clang>: $<$<NOT:$<CONFIG:DEBUG>>:-O3> $<$<CONFIG:DEBUG>:-O0>>
            )
    endif()

    if (MAiNGO_build_python_interface)
        set(PYTHON_TEST_DIR ${PROJECT_SOURCE_DIR}/maingopy/tests)
        add_custom_target(test-maingopy ALL
            COMMAND ${CMAKE_COMMAND} -E copy
                ${PYTHON_TEST_DIR}/testMaingopy.py
                $<$<CONFIG:Debug>:${RUNTIME_OUTPUT_DIRECTORY_DEBUG}>$<$<NOT:$<CONFIG:Debug>>:${RUNTIME_OUTPUT_DIRECTORY_RELEASE}>
            COMMAND ${CMAKE_COMMAND} -E make_directory
                $<$<CONFIG:Debug>:${RUNTIME_OUTPUT_DIRECTORY_DEBUG}>$<$<NOT:$<CONFIG:Debug>>:${RUNTIME_OUTPUT_DIRECTORY_RELEASE}>/individualPythonTests
            COMMAND ${CMAKE_COMMAND} -E copy
                ${PYTHON_TEST_DIR}/individualPythonTests/testEvaluationContainer.py
                ${PYTHON_TEST_DIR}/individualPythonTests/testIntrinsicFunctions.py
                ${PYTHON_TEST_DIR}/individualPythonTests/testMAiNGOmodel.py
                ${PYTHON_TEST_DIR}/individualPythonTests/testOptimizationVariables.py
                ${PYTHON_TEST_DIR}/individualPythonTests/testSolver.py
                ${PYTHON_TEST_DIR}/individualPythonTests/__init__.py
                $<$<CONFIG:Debug>:${RUNTIME_OUTPUT_DIRECTORY_DEBUG}>$<$<NOT:$<CONFIG:Debug>>:${RUNTIME_OUTPUT_DIRECTORY_RELEASE}>/individualPythonTests
            COMMAND ${CMAKE_COMMAND} -E copy
                ${PROJECT_SOURCE_DIR}/examples/MAiNGOSettings.txt
                $<$<CONFIG:Debug>:${RUNTIME_OUTPUT_DIRECTORY_DEBUG}>$<$<NOT:$<CONFIG:Debug>>:${RUNTIME_OUTPUT_DIRECTORY_RELEASE}>/individualPythonTests
            )
    endif()

endif()