summaryrefslogtreecommitdiff
path: root/math/osqp/files/patch-CMakeLists.txt
blob: 85e0b950bff2aa960de29d45ef50a0aa07081658 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
--- CMakeLists.txt.orig	2023-05-25 14:48:50 UTC
+++ CMakeLists.txt
@@ -272,28 +272,32 @@ endif (R_LANG)
 add_subdirectory(lin_sys)
 
 # Static library
-add_library (osqpstatic STATIC ${osqp_src} ${osqp_headers} ${linsys_solvers})
-# Give same name to static library output
-set_target_properties(osqpstatic PROPERTIES OUTPUT_NAME osqp)
+if (BUILD_STATIC_LIBS)
+    add_library (osqp STATIC ${osqp_src} ${osqp_headers} ${linsys_solvers})
+    # Give same name to static library output
+    set_target_properties(osqp PROPERTIES OUTPUT_NAME osqp)
 
-# Include directories for linear system solvers
-target_include_directories(osqpstatic PRIVATE ${linsys_solvers_includes})
+    # Include directories for linear system solvers
+    target_include_directories(osqp PRIVATE ${linsys_solvers_includes})
 
-# Declare include directories for the cmake exported target
-target_include_directories(osqpstatic
-                           PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
-                                  "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}/osqp>")
+    # Declare include directories for the cmake exported target
+    target_include_directories(osqp
+                               PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
+                                      "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}/osqp>")
+endif()
 
 # Install Static Library
 # ----------------------------------------------
 
 include(GNUInstallDirs)
 
-install(TARGETS osqpstatic
-        EXPORT  ${PROJECT_NAME}
-        ARCHIVE       DESTINATION "${CMAKE_INSTALL_LIBDIR}"
-        LIBRARY       DESTINATION "${CMAKE_INSTALL_LIBDIR}"
-        RUNTIME       DESTINATION "${CMAKE_INSTALL_BINDIR}")
+if (BUILD_STATIC_LIBS)
+    install(TARGETS osqp
+            EXPORT  ${PROJECT_NAME}
+            ARCHIVE       DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+            LIBRARY       DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+            RUNTIME       DESTINATION "${CMAKE_INSTALL_BINDIR}")
+endif()
 
 
 # Install Headers
@@ -304,7 +308,7 @@ install(FILES ${osqp_headers} DESTINATION "${CMAKE_INS
 
 
 if (MATLAB)
-target_link_libraries (osqpstatic ${Matlab_LIBRARIES})
+target_link_libraries (osqp ${Matlab_LIBRARIES})
 endif (MATLAB)
 
 # If we are building Python/Matlab/R interface:
@@ -331,8 +335,10 @@ if (NOT PYTHON AND NOT MATLAB AND NOT R_LANG AND NOT E
             RUNTIME       DESTINATION "${CMAKE_INSTALL_BINDIR}")
 
     # Create demo executable (linked to static library)
-    add_executable (osqp_demo ${PROJECT_SOURCE_DIR}/examples/osqp_demo.c)
-    target_link_libraries (osqp_demo osqpstatic)
+    if (BUILD_EXAMPLES)
+        add_executable (osqp_demo ${PROJECT_SOURCE_DIR}/examples/osqp_demo.c)
+        target_link_libraries (osqp_demo osqp)
+    endif()
 
 endif (NOT PYTHON AND NOT MATLAB AND NOT R_LANG AND NOT EMBEDDED)
 
@@ -431,7 +437,7 @@ if (UNITTESTS)
                 CXX_STANDARD_REQUIRED YES
                 CXX_EXTENSIONS NO
             )
-    target_link_libraries (osqp_tester osqpstatic ${CMAKE_DL_LIBS})
+    target_link_libraries (osqp_tester osqp ${CMAKE_DL_LIBS})
 
     # Add custom memory target
     add_executable(osqp_tester_custom_memory
@@ -443,7 +449,7 @@ if (UNITTESTS)
 		   ${PROJECT_SOURCE_DIR}/tests/custom_memory/custom_memory.c
 		   ${PROJECT_SOURCE_DIR}/tests/custom_memory/custom_memory.h
 		)
-    target_link_libraries (osqp_tester_custom_memory osqpstatic ${CMAKE_DL_LIBS})
+    target_link_libraries (osqp_tester_custom_memory osqp ${CMAKE_DL_LIBS})
 
     # Add testing
     include(CTest)