hackrf/host/libhackrf/src/CMakeLists.txt
Michael Ossmann aa0485d4df Revert "Cleanup of host software CMake build system (#664)"
This reverts commit d60fb83320cea49fd20305f22838f948557f1b81.
2021-12-08 16:59:05 -07:00

82 lines
3.3 KiB
CMake

#
# Copyright (c) 2012, Jared Boone <jared@sharebrained.com>
# Copyright (c) 2013, Benjamin Vernoux <titanmkd@gmail.com>
# Copyright (c) 2013, Michael Ossmann <mike@ossmann.com>
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
#
# Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
# Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# Neither the name of Great Scott Gadgets nor the names of its contributors may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Based heavily upon the libftdi cmake setup.
# Targets
set(c_sources ${CMAKE_CURRENT_SOURCE_DIR}/hackrf.c CACHE INTERNAL "List of C sources")
set(c_headers ${CMAKE_CURRENT_SOURCE_DIR}/hackrf.h CACHE INTERNAL "List of C headers")
# Dynamic library
add_library(hackrf SHARED ${c_sources})
set_target_properties(hackrf PROPERTIES VERSION ${MAJOR_VERSION}.${MINOR_VERSION}.0 SOVERSION 0)
# Static library
add_library(hackrf-static STATIC ${c_sources})
if(MSVC)
set_target_properties(hackrf-static PROPERTIES OUTPUT_NAME "hackrf_static")
else()
set_target_properties(hackrf-static PROPERTIES OUTPUT_NAME "hackrf")
endif()
set_target_properties(hackrf PROPERTIES CLEAN_DIRECT_OUTPUT 1)
set_target_properties(hackrf-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
# Dependencies
target_link_libraries(hackrf ${LIBUSB_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
# For cygwin just force UNIX OFF and WIN32 ON
if( ${CYGWIN} )
SET(UNIX OFF)
SET(WIN32 ON)
endif( ${CYGWIN} )
if( ${UNIX} )
install(TARGETS hackrf
LIBRARY DESTINATION lib${LIB_SUFFIX}
COMPONENT sharedlibs
)
install(TARGETS hackrf-static
ARCHIVE DESTINATION lib${LIB_SUFFIX}
COMPONENT staticlibs
)
install(FILES ${c_headers}
DESTINATION include/${PROJECT_NAME}
COMPONENT headers
)
endif( ${UNIX} )
if( ${WIN32} )
install(TARGETS hackrf
DESTINATION bin
COMPONENT sharedlibs
)
install(TARGETS hackrf-static
DESTINATION bin
COMPONENT staticlibs
)
install(FILES ${c_headers}
DESTINATION include/${PROJECT_NAME}
COMPONENT headers
)
endif( ${WIN32} )