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 90 91
|
#-------------------------------------------------------------------------------
# SuiteSparse/TestConfig/Mongoose/CMakeLists.txt: cmake for project linking to Mongoose
#-------------------------------------------------------------------------------
# Copyright (c) 2024, Timothy A. Davis, All Rights Reserved.
# SPDX-License-Identifier: BSD-3-clause
cmake_minimum_required ( VERSION 3.22 )
#-------------------------------------------------------------------------------
# configure options
#-------------------------------------------------------------------------------
option ( BUILD_SHARED_LIBS "OFF: do not build shared libraries. ON (default): build shared libraries" ON )
option ( BUILD_STATIC_LIBS "OFF: do not build static libraries. ON (default): build static libraries" ON )
#-------------------------------------------------------------------------------
# variables
#-------------------------------------------------------------------------------
set ( TEST_PROJECT_NAME mongoose_demo )
set ( TEST_PACKAGE_NAME SuiteSparse_Mongoose )
set ( TEST_SHARED_BIN mongoose_demo )
set ( TEST_STATIC_BIN mongoose_demo_static )
set ( TEST_IMPORT_TARGET SuiteSparse::Mongoose )
set ( TEST_IMPORT_TARGET_STATIC SuiteSparse::Mongoose_static )
#-------------------------------------------------------------------------------
# define project
#-------------------------------------------------------------------------------
project ( ${TEST_PROJECT_NAME} LANGUAGES C CXX )
#-------------------------------------------------------------------------------
# find library dependencies
#-------------------------------------------------------------------------------
find_package ( ${TEST_PACKAGE_NAME} REQUIRED )
#-------------------------------------------------------------------------------
# dynamically linked executable properties
#-------------------------------------------------------------------------------
file ( GLOB MY_SOURCES "*.cc" )
if ( BUILD_SHARED_LIBS )
add_executable ( ${TEST_SHARED_BIN} ${MY_SOURCES} )
set_target_properties ( ${TEST_SHARED_BIN} PROPERTIES
C_STANDARD 11
C_STANDARD_REQUIRED ON )
endif ( )
#-------------------------------------------------------------------------------
# staticcally linked executable properties
#-------------------------------------------------------------------------------
if ( BUILD_STATIC_LIBS )
add_executable ( ${TEST_STATIC_BIN} ${MY_SOURCES} )
set_target_properties ( ${TEST_STATIC_BIN} PROPERTIES
C_STANDARD 11
C_STANDARD_REQUIRED ON )
endif ( )
#-------------------------------------------------------------------------------
# add library dependency
#-------------------------------------------------------------------------------
if ( BUILD_SHARED_LIBS )
target_link_libraries ( ${TEST_SHARED_BIN} PRIVATE ${TEST_IMPORT_TARGET} )
endif ( )
if ( BUILD_STATIC_LIBS )
if ( TARGET ${TEST_IMPORT_TARGET_STATIC} )
target_link_libraries ( ${TEST_STATIC_BIN} PUBLIC ${TEST_IMPORT_TARGET_STATIC} )
else ( )
target_link_libraries ( ${TEST_STATIC_BIN} PUBLIC ${TEST_IMPORT_TARGET} )
endif ( )
endif ( )
#-------------------------------------------------------------------------------
# installation location
#-------------------------------------------------------------------------------
include ( GNUInstallDirs )
if ( BUILD_SHARED_LIBS )
install ( TARGETS ${TEST_SHARED_BIN}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
endif ( )
if ( BUILD_STATIC_LIBS )
install ( TARGETS ${TEST_STATIC_BIN}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
endif ( )
|