- Merged with upstream version
[rtl-433.git] / CMakeLists.txt
1 # rtl_433 is distributed in the hope that it will be useful,
2 # but WITHOUT ANY WARRANTY; without even the implied warranty of
3 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4 # GNU General Public License for more details.
5 #
6 # You should have received a copy of the GNU General Public License
7 # along with GNU Radio; see the file COPYING.  If not, write to
8 # the Free Software Foundation, Inc., 51 Franklin Street,
9 # Boston, MA 02110-1301, USA.
10
11
12 ########################################################################
13 # Project setup
14 ########################################################################
15 cmake_minimum_required(VERSION 2.6)
16 project(rtl433 C)
17 set (rtl433_VERSION_MAJOR 1)
18 set (rtl433_VERSION_MINOR 0)
19
20 #select the release build type by default to get optimization flags
21 if(NOT CMAKE_BUILD_TYPE)
22    set(CMAKE_BUILD_TYPE "Release")
23    message(STATUS "Build type not specified: defaulting to release.")
24 endif(NOT CMAKE_BUILD_TYPE)
25 set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "")
26
27 list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
28
29 ########################################################################
30 # Compiler specific setup
31 ########################################################################
32 if(CMAKE_COMPILER_IS_GNUCC AND NOT WIN32)
33     ADD_DEFINITIONS(-Wall)
34     ADD_DEFINITIONS(-Wextra)
35     ADD_DEFINITIONS(-Wno-unused)
36     ADD_DEFINITIONS(-Wsign-compare)
37     ADD_DEFINITIONS(-g3 -O0)
38     #http://gcc.gnu.org/wiki/Visibility
39     add_definitions(-fvisibility=hidden)
40 endif()
41
42 ########################################################################
43 # Find build dependencies
44 ########################################################################
45 find_package(PkgConfig)
46 find_package(LibRTLSDR)
47
48 ########################################################################
49 # Setup the include and linker paths
50 ########################################################################
51 include_directories(
52     ${CMAKE_SOURCE_DIR}/include
53         ${LIBRTLSDR_INCLUDE_DIRS}
54 )
55
56 ########################################################################
57 # Create uninstall target
58 ########################################################################
59 configure_file(
60     ${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in
61     ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
62 @ONLY)
63
64 add_custom_target(uninstall
65     ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
66 )
67
68 ########################################################################
69 # Add subdirectories
70 ########################################################################
71 add_subdirectory(include)
72 add_subdirectory(src)
73
74 # use space-separation format for the pc file
75 STRING(REPLACE ";" " " RTL433_PC_CFLAGS "${RTL433_PC_CFLAGS}")
76 STRING(REPLACE ";" " " RTL433_PC_LIBS "${RTL433_PC_LIBS}")
77
78 # unset these vars to avoid hard-coded paths to cross environment
79 IF(CMAKE_CROSSCOMPILING)
80     UNSET(RTL433_PC_CFLAGS)
81     UNSET(RTL433_PC_LIBS)
82 ENDIF(CMAKE_CROSSCOMPILING)
83
84 set(prefix ${CMAKE_INSTALL_PREFIX})
85 set(exec_prefix \${prefix})
86 set(libdir \${exec_prefix}/lib)
87 set(includedir \${prefix}/include)
88
89 INSTALL(
90     FILES
91     DESTINATION lib/pkgconfig
92 )