vendor/scs/CMakeLists.txt in scs-0.3.1 vs vendor/scs/CMakeLists.txt in scs-0.3.2
- old
+ new
@@ -3,11 +3,11 @@
cmake_minimum_required(VERSION 3.5)
project(scs
LANGUAGES C
- VERSION 2.1.4)
+ VERSION 3.1.1)
# Defines the CMAKE_INSTALL_LIBDIR, CMAKE_INSTALL_BINDIR and many other useful macros.
# See https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html
include(GNUInstallDirs)
@@ -86,18 +86,62 @@
option(BUILD_TESTING "Create tests using CMake" OFF)
if(BUILD_TESTING)
enable_testing()
endif()
+# Add uninstall target
+# After 'make install' can run 'make uninstall' to remove.
+include(AddUninstallTarget)
+
### Some variables useful for sampling the building process
# Note that the GPU profile is not compiled.
set(LINSYS linsys)
set(DIRSRC ${LINSYS}/cpu/direct)
set(INDIRSRC ${LINSYS}/cpu/indirect)
set(EXTERNAL ${LINSYS}/external)
+# Options
+# ----------------------------------------------
+# Use floats instead of doubles
+option(SFLOAT "Use single precision floats rather than doubles" OFF)
+message(STATUS "Single precision floats (32bit) are ${SFLOAT}")
+# Use long integers for indexing
+option(DLONG "Use long integers (64bit) for indexing" OFF)
+message(STATUS "Long integers (64bit) are ${DLONG}")
+
+
+set(COMPILER_OPTS "-DUSE_LAPACK -DCOPYAMATRIX -DCTRLC")
+
+# Primitive types
+if(SFLOAT)
+ set(SCS_FLOAT_TYPE "float")
+ set(COMPILER_OPTS "-DSFLOAT ${COMPILER_OPTS}")
+else()
+ set(SCS_FLOAT_TYPE "double")
+endif()
+
+if(DLONG)
+ set(SCS_INT_TYPE "long long")
+ set(COMPILER_OPTS "-DDLONG ${COMPILER_OPTS}")
+else()
+ set(SCS_INT_TYPE "int")
+endif()
+
+message(STATUS "COMPILER_OPTS = ${COMPILER_OPTS}")
+
+# TODO this is a hack that overwrites the scs_types.h file, we should
+# find a way to do this that doesn't pollute the master directory.
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/scs_types.h.in
+ ${CMAKE_CURRENT_SOURCE_DIR}/include/scs_types.h
+ NEWLINE_STYLE LF)
+
+# Public headers
+set(${PROJECT_NAME}_PUBLIC_HDR
+ include/scs_types.h
+ include/scs.h)
+
# Common source files
set(${PROJECT_NAME}_SRC
src/aa.c
src/cones.c
src/ctrlc.c
@@ -120,10 +164,12 @@
include/linsys.h
include/normalize.h
include/rw.h
include/scs.h
include/scs_blas.h
+ include/scs_types.h
+ include/scs_work.h
include/util.h
${LINSYS}/csparse.h
${LINSYS}/scs_matrix.h)
# get all the c file in amd/external
@@ -160,22 +206,22 @@
target_include_directories(${${PROJECT_NAME}_DIRECT} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/scs>")
# Compiled with blas and lapack, can solve LPs, SOCPs, SDPs, ECPs, and PCPs
-target_compile_definitions(${${PROJECT_NAME}_DIRECT} PRIVATE -DUSE_LAPACK -DCOPYAMATRIX -DCTRLC)
+target_compile_definitions(${${PROJECT_NAME}_DIRECT} PRIVATE ${COMPILER_OPTS})
# The library depends on math (m) blas and lapack
target_link_libraries(${${PROJECT_NAME}_DIRECT} PRIVATE
m
blas
lapack)
# Set some properties
set_target_properties(${${PROJECT_NAME}_DIRECT} PROPERTIES
VERSION ${scs_VERSION}
- PUBLIC_HEADER "${${PROJECT_NAME}_HDR}")
+ PUBLIC_HEADER "${${PROJECT_NAME}_PUBLIC_HDR}")
add_library(scs::${${PROJECT_NAME}_DIRECT} ALIAS ${${PROJECT_NAME}_DIRECT})
# Install the library
install(TARGETS ${${PROJECT_NAME}_DIRECT}
@@ -207,22 +253,22 @@
target_include_directories(${${PROJECT_NAME}_INDIRECT} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/scs>")
# Compiled with blas and lapack, can solve LPs, SOCPs, SDPs, ECPs, and PCPs
-target_compile_definitions(${${PROJECT_NAME}_INDIRECT} PRIVATE -DUSE_LAPACK -DCOPYAMATRIX -DCTRLC -DINDIRECT)
+target_compile_definitions(${${PROJECT_NAME}_INDIRECT} PRIVATE ${COMPILER_OPTS} -DINDIRECT)
# The library depends on math (m) blas and lapack
target_link_libraries(${${PROJECT_NAME}_INDIRECT} PUBLIC
m
blas
lapack)
# Set some properties
set_target_properties(${${PROJECT_NAME}_INDIRECT} PROPERTIES
VERSION ${scs_VERSION}
- PUBLIC_HEADER "${${${PROJECT_NAME}_INDIRECT}_HDR}")
+ PUBLIC_HEADER "${${PROJECT_NAME}_PUBLIC_HDR}")
add_library(scs::${${PROJECT_NAME}_INDIRECT} ALIAS ${${PROJECT_NAME}_INDIRECT})
# Install the library
install(TARGETS ${${PROJECT_NAME}_INDIRECT}
@@ -248,23 +294,25 @@
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
### Add the tests
if(BUILD_TESTING)
add_executable(run_tests_direct test/run_tests.c)
+ target_compile_definitions(run_tests_direct PRIVATE ${COMPILER_OPTS})
target_link_libraries(run_tests_direct PRIVATE
scs::scsdir)
target_include_directories(run_tests_direct PRIVATE
- "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test;${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>")
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test;${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>" )
add_test(NAME run_tests_direct
COMMAND run_tests_direct
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_executable(run_tests_indirect test/run_tests.c)
+ target_compile_definitions(run_tests_indirect PRIVATE ${COMPILER_OPTS})
target_link_libraries(run_tests_indirect PRIVATE
scs::scsindir)
target_include_directories(run_tests_indirect PRIVATE
- "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test;${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>")
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test;${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_CURRENT_SOURCE_DIR}/${LINSYS}>" )
add_test(NAME run_tests_indirect
COMMAND run_tests_indirect
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})