Statistics
| Branch: | Tag: | Revision:

root / host / lib / CMakeLists.txt @ b221b3e3

History | View | Annotate | Download (4.43 KB)

1 8d76c9a4 Josh Blum
#
2 91790751 Josh Blum
# Copyright 2010-2011 Ettus Research LLC
3 8d76c9a4 Josh Blum
#
4
# This program is free software: you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation, either version 3 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
#
17
18 fdd80e54 Josh Blum
########################################################################
19 1acc7467 Josh Blum
# Helpful Macros
20 5715b2c4 Josh Blum
########################################################################
21 1acc7467 Josh Blum
MACRO(LIBUHD_APPEND_SOURCES)
22
    LIST(APPEND libuhd_sources ${ARGV})
23
ENDMACRO(LIBUHD_APPEND_SOURCES)
24 8d76c9a4 Josh Blum
25 f159e4e3 Josh Blum
MACRO(LIBUHD_APPEND_LIBS)
26
    LIST(APPEND libuhd_libs ${ARGV})
27
ENDMACRO(LIBUHD_APPEND_LIBS)
28
29 1acc7467 Josh Blum
MACRO(LIBUHD_PYTHON_GEN_SOURCE pyfile outfile)
30 6b015b1c Josh Blum
    #ensure that the directory exists for outfile
31
    GET_FILENAME_COMPONENT(outfile_dir ${outfile} PATH)
32
    FILE(MAKE_DIRECTORY ${outfile_dir})
33
34
    #make the outfile depend on the python script
35 fdd80e54 Josh Blum
    ADD_CUSTOM_COMMAND(
36 f57ef3e7 Josh Blum
        OUTPUT ${outfile} DEPENDS ${pyfile} ${LIBUHD_PYTHON_GEN_SOURCE_DEPS}
37 805ba035 Josh Blum
        COMMAND ${PYTHON_EXECUTABLE} -B ${pyfile} ${outfile}
38 77c578fc Josh Blum
        COMMENT "Generating ${outfile}"
39 fdd80e54 Josh Blum
    )
40 6b015b1c Josh Blum
41
    #make libuhd depend on the outfile
42 1acc7467 Josh Blum
    LIBUHD_APPEND_SOURCES(${outfile})
43
ENDMACRO(LIBUHD_PYTHON_GEN_SOURCE)
44 d91c18e6 Josh Blum
45 42ed1d34 Josh Blum
MACRO(INCLUDE_SUBDIRECTORY subdir)
46
    #insert the current directories on the front of the list
47
    LIST(INSERT _cmake_source_dirs 0 ${CMAKE_CURRENT_SOURCE_DIR})
48
    LIST(INSERT _cmake_binary_dirs 0 ${CMAKE_CURRENT_BINARY_DIR})
49
50
    #set the current directories to the names of the subdirs
51
    SET(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${subdir})
52
    SET(CMAKE_CURRENT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${subdir})
53
54
    #include the subdirectory CMakeLists to run it
55
    FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
56
    INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt)
57
58
    #reset the value of the current directories
59
    LIST(GET _cmake_source_dirs 0 CMAKE_CURRENT_SOURCE_DIR)
60
    LIST(GET _cmake_binary_dirs 0 CMAKE_CURRENT_BINARY_DIR)
61
62
    #pop the subdir names of the front of the list
63
    LIST(REMOVE_AT _cmake_source_dirs 0)
64
    LIST(REMOVE_AT _cmake_binary_dirs 0)
65
ENDMACRO(INCLUDE_SUBDIRECTORY)
66
67 d91c18e6 Josh Blum
########################################################################
68 42ed1d34 Josh Blum
# Include subdirectories (different than add)
69 ad0d641b Josh Blum
########################################################################
70 42ed1d34 Josh Blum
INCLUDE_SUBDIRECTORY(ic_reg_maps)
71 fd9962af Josh Blum
INCLUDE_SUBDIRECTORY(types)
72 91790751 Josh Blum
INCLUDE_SUBDIRECTORY(convert)
73 42ed1d34 Josh Blum
INCLUDE_SUBDIRECTORY(transport)
74
INCLUDE_SUBDIRECTORY(usrp)
75
INCLUDE_SUBDIRECTORY(utils)
76 4efafcc2 Josh Blum
77
########################################################################
78 00bc8d50 Josh Blum
# Setup UHD_VERSION_STRING for version.cpp
79 08f6b21c Josh Blum
########################################################################
80 c463c42f Josh Blum
CONFIGURE_FILE(
81 00bc8d50 Josh Blum
    ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp
82 c463c42f Josh Blum
    ${CMAKE_CURRENT_BINARY_DIR}/version.cpp
83
@ONLY)
84 d63390a1 Josh Blum
85 81e891f3 Josh Blum
########################################################################
86
# Append to the list of sources for lib uhd
87
########################################################################
88 1acc7467 Josh Blum
LIBUHD_APPEND_SOURCES(
89 bf5aba2d Josh Blum
    ${CMAKE_CURRENT_SOURCE_DIR}/deprecated.cpp
90 1acc7467 Josh Blum
    ${CMAKE_CURRENT_SOURCE_DIR}/device.cpp
91 20a524d1 Josh Blum
    ${CMAKE_CURRENT_SOURCE_DIR}/exception.cpp
92 81c15fea Josh Blum
    ${CMAKE_CURRENT_SOURCE_DIR}/property_tree.cpp
93 c463c42f Josh Blum
    ${CMAKE_CURRENT_BINARY_DIR}/version.cpp
94 1acc7467 Josh Blum
)
95 08f6b21c Josh Blum
96
########################################################################
97 5715b2c4 Josh Blum
# Setup libuhd library
98
########################################################################
99 b4e5df40 Josh Blum
ADD_LIBRARY(uhd SHARED ${libuhd_sources})
100 f159e4e3 Josh Blum
TARGET_LINK_LIBRARIES(uhd ${Boost_LIBRARIES} ${libuhd_libs})
101 35bcf1c6 Josh Blum
SET_TARGET_PROPERTIES(uhd PROPERTIES DEFINE_SYMBOL "UHD_DLL_EXPORTS")
102 d078d4f5 Josh Blum
SET_TARGET_PROPERTIES(uhd PROPERTIES SOVERSION "${UHD_VERSION_MAJOR}")
103 1ff8aaea Josh Blum
SET_TARGET_PROPERTIES(uhd PROPERTIES VERSION "${UHD_VERSION_MAJOR}.${UHD_VERSION_MINOR}")
104 8878b35d Josh Blum
IF(DEFINED LIBUHD_OUTPUT_NAME)
105
    SET_TARGET_PROPERTIES(uhd PROPERTIES OUTPUT_NAME ${LIBUHD_OUTPUT_NAME})
106
ENDIF(DEFINED LIBUHD_OUTPUT_NAME)
107 35bcf1c6 Josh Blum
108 69aaffa6 Josh Blum
INSTALL(TARGETS uhd
109 69d19fed Josh Blum
    LIBRARY DESTINATION ${LIBRARY_DIR} COMPONENT libraries # .so file
110
    ARCHIVE DESTINATION ${LIBRARY_DIR} COMPONENT libraries # .lib file
111 1721352e Josh Blum
    RUNTIME DESTINATION ${RUNTIME_DIR} COMPONENT libraries # .dll file
112 69aaffa6 Josh Blum
)