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 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
######################################################################
# CMakeLists.txt - cmake build file to create CVector #
# #
# Version 1.0.4 26 November 2014 #
# Rev 23 November 2014 #
# #
# Herbert J. Bernstein (yayahjb@gmail.com) #
# #
# (C) Copyright 2008 - 2014 Herbert J. Bernstein #
# #
######################################################################
######################################################################
# #
# YOU MAY REDISTRIBUTE THE CVector API UNDER THE TERMS OF THE LGPL #
# #
######################################################################
######################################################################
# #
# This library is free software; you can redistribute it and/or #
# modify it under the terms of the GNU Lesser General Public #
# License as published by the Free Software Foundation; either #
# version 2.1 of the License, or (at your option) any later version. #
# #
# This library is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
# Lesser General Public License for more details. #
# #
# You should have received a copy of the GNU Lesser General Public #
# License along with this library; if not, write to the Free #
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, #
# MA 02110-1301 USA #
# #
######################################################################
cmake_minimum_required (VERSION 2.8.7)
project (CVector C)
set(CV_APIVERS,"2.0.0")
#
# Environment Variables
#
set(CV_USE_LOCAL_HEADERS_ENV $ENV{CV_USE_LOCAL_HEADERS})
if (CV_USE_LOCAL_HEADERS_ENV STREQUAL "YES")
set(COMPILE_DEFINITIONS "USE_LOCAL_HEADERS=1")
endif (CV_USE_LOCAL_HEADERS_ENV STREQUAL "YES")
#
# Directories
#
#
# Directories on the kit side
#
set(CV__SRC "${CVector_SOURCE_DIR}" )
set(CV__INCLUDE "${CVector_SOURCE_DIR}" )
set(CV__EXAMPLES "${CVector_SOURCE_DIR}" )
set(CV__TESTDATA "${CVector_SOURCE_DIR}" )
#
# Directories on the build side
#
set(CV__BIN "${CVector_BINARY_DIR}/bin" )
set(CV__LIB "${CVector_BINARY_DIR}/lib" )
#
# CV_REQUIRE_DIRECTORY -- require directory dir
#
macro(CV_REQUIRE_DIRECTORY dir)
if (NOT EXISTS "${dir}")
file(MAKE_DIRECTORY "${dir}")
CBF_DEBUG_MESSAGE("Created directory ${dir}")
endif (NOT EXISTS "${dir}")
endmacro(CV_REQUIRE_DIRECTORY)
CV_REQUIRE_DIRECTORY(${CV__BIN})
CV_REQUIRE_DIRECTORY(${CV__LIB})
#
# Source files
#
set(
CV_C_SOURCES
${CV__SRC}/CVector.c
)
set(
CV_HEADERS
${CV__INCLUDE}/CVector.h
)
# Set up the necessary includes
include_directories(
BEFORE SYSTEM
${CV__INCLUDE}
)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CV__BIN}")
#
# Build the static and shared CVector libraries
#
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CV__LIB}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CV__LIB}")
add_library(CV_static STATIC ${CV__SRC}/CVector.c)
set_target_properties(CV_static PROPERTIES OUTPUT_NAME "CVector")
set_target_properties(CV_static PROPERTIES LINKER_LANGUAGE C)
set_target_properties(CV_static PROPERTIES SOVERSION "${CV_APIVERSION}")
set(CV_STATIC_LIBRARY_PATH ${CV__LIB}/libCVector${CMAKE_STATIC_LIBRARY_SUFFIX})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CV__LIB}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CV__LIB}")
add_library(CV_shared SHARED ${CV__SRC}/CVector.c)
set_target_properties(CV_shared PROPERTIES OUTPUT_NAME "CVector")
set_target_properties(CV_shared PROPERTIES LINKER_LANGUAGE C)
set_target_properties(CV_shared PROPERTIES SOVERSION "${CV_APIVERSION}")
set(CV_SHARED_LIBRARY_PATH ${CV__LIB}/libCVector.${CMAKE_SHARED_LIBRARY_SUFFIX})
#
# C examples
#
# Note: to add a target with multiple sources/dependencies/libraries you must pass a list
# separated by semicolons for the appropriate parameter.
# Note: the math library should be linked in by appending ';m' to the library list here
macro(add_target target source dependencies libraries)
add_executable(${target} ${source})
add_dependencies(${target} ${dependencies})
target_link_libraries(${target} ${libraries})
endmacro()
add_executable(CVectorBasicTest "${CV__EXAMPLES}/CVectorBasicTest.c")
set_target_properties(CVectorBasicTest PROPERTIES LINK_LIBRARIES CV_static)
#
# install
#
install (TARGETS CVectorBasicTest DESTINATION bin)
install (TARGETS CV_static DESTINATION lib)
install (TARGETS CV_shared DESTINATION lib)
#
# test
#
enable_testing()
add_test(CVectorBasicTest ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/CVectorBasicTest CVectorBasicTest.lst)
add_test(cmp-CVectorBasicTest_orig.lst-CVectorBasicTest.lst ${CMAKE_COMMAND} -E compare_files ${CV__TESTDATA}/CVectorBasicTest_orig.lst CVectorBasicTest.lst)
|