HBASE-19906 TestZooKeeper Timeout Includes move of TestQoSFunction from smalltests...
[hbase.git] / hbase-native-client / CMakeLists.txt
blob819f178111252671e2b748583191e6ac0c7b993a
1 # Licensed to the Apache Software Foundation (ASF) under one
2 # or more contributor license agreements.  See the NOTICE file
3 # distributed with this work for additional information
4 # regarding copyright ownership.  The ASF licenses this file
5 # to you under the Apache License, Version 2.0 (the
6 # "License"); you may not use this file except in compliance
7 # with the License.  You may obtain a copy of the License at
9 #   http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing,
12 # software distributed under the License is distributed on an
13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 # KIND, either express or implied.  See the License for the
15 # specific language governing permissions and limitations
16 # under the License.
18 cmake_minimum_required(VERSION 2.6)
20 # generate CTest input files
21 enable_testing()
23 # where to find cmake modules
24 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules")
26 # if no build build type is specified, default to debug builds
27 if (NOT CMAKE_BUILD_TYPE)
28   set(CMAKE_BUILD_TYPE Debug)
29 endif(NOT CMAKE_BUILD_TYPE)
31 STRING(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
33 set(CXX_COMMON_FLAGS "-Wall -Wextra -std=c++11")
34 set(C_COMMON_FLAGS "-Wall -Wextra -std=c11")
36 set(CXX_FLAGS_DEBUG "-ggdb -g")
37 set(C_FLAGS_DEBUG "-ggdb")
39 set(CXX_FLAGS_FASTDEBUG "-ggdb -O1")
40 set(C_FLAGS_FASTDEBUG "-ggdb -O1")
42 set(CXX_FLAGS_RELEASE "-O3 -g -DNDEBUG -Wno-strict-aliasing")
43 set(C_FLAGS_RELEASE "-O3 -g -DNDEBUG -Wno-strict-aliasing")
45 # if no build build type is specified, default to debug builds
46 if (NOT CMAKE_BUILD_TYPE)
47   set(CMAKE_BUILD_TYPE Debug)
48 endif(NOT CMAKE_BUILD_TYPE)
50 string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
52 # Set compile flags based on the build type.
53 message("Configured for ${CMAKE_BUILD_TYPE} build (set with cmake -DCMAKE_BUILD_TYPE={release,debug,...})")
54 if ("${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG")
55   set(CMAKE_CXX_FLAGS ${CXX_FLAGS_DEBUG})
56   set(CMAKE_C_FLAGS ${C_FLAGS_DEBUG})
57 elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "FASTDEBUG")
58   set(CMAKE_CXX_FLAGS ${CXX_FLAGS_FASTDEBUG})
59   set(CMAKE_C_FLAGS ${C_FLAGS_FASTDEBUG})
60 elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "RELEASE")
61   set(CMAKE_CXX_FLAGS ${CXX_FLAGS_RELEASE})
62   set(CMAKE_C_FLAGS ${C_FLAGS_RELEASE})
63 else()
64   message(FATAL_ERROR "Unknown build type: ${CMAKE_BUILD_TYPE}")
65 endif ()
67 set(CMAKE_CXX_FLAGS "${CXX_COMMON_FLAGS} ${CMAKE_CXX_FLAGS}")
68 set(CMAKE_C_FLAGS "${C_COMMON_FLAGS} ${CMAKE_C_FLAGS}")
71 # set compile output directory
72 string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_LOWERCASE)
73 set(BUILD_OUTPUT_ROOT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/build/${CMAKE_BUILD_TYPE_LOWERCASE}/")
75 # Link build/latest to the current build directory, to avoid developers
76 # accidentally running the latest debug build when in fact they're building
77 # release builds.
78 file(MAKE_DIRECTORY ${BUILD_OUTPUT_ROOT_DIRECTORY})
79 execute_process(COMMAND rm -f ${CMAKE_CURRENT_SOURCE_DIR}/build/latest)
80 execute_process(COMMAND ln -sf ${BUILD_OUTPUT_ROOT_DIRECTORY}
81   ${CMAKE_CURRENT_SOURCE_DIR}/build/latest)
83 # where to put generated libraries
84 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${BUILD_OUTPUT_ROOT_DIRECTORY}")
85 set(ARCHIVE_OUTPUT_DIRECTORY "${BUILD_OUTPUT_ROOT_DIRECTORY}")
86 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${BUILD_OUTPUT_ROOT_DIRECTORY}")
88 # where to put generated binaries
89 set(EXECUTABLE_OUTPUT_PATH "${BUILD_OUTPUT_ROOT_DIRECTORY}")
91 include_directories(src)
93 #####################
94 # Third Party
95 #####################
97 # find boost headers and libs
98 set(Boost_DEBUG TRUE)
99 set(Boost_USE_MULTITHREADED ON)
100 find_package(Boost REQUIRED COMPONENTS thread system-mt)
101 include_directories(${Boost_INCLUDE_DIRS})
103 find_package(Protobuf REQUIRED)
104 include_directories(${PROTOBUF_INCLUDE_DIRS})
105 add_library(protobuf STATIC IMPORTED)
106 set_target_properties(protobuf PROPERTIES IMPORTED_LOCATION "${PROTOBUF_STATIC_LIBRARY}")
108 find_package(LibEv REQUIRED)
109 include_directories(${LIBEV_INCLUDE_DIR})
110 add_library(libev STATIC IMPORTED)
113 set(HBASE_LIBS
114     ${PROTOBUF}
115     ${LIBEV}
116     ${Boost_LIBRARIES}
118 #########
119 # Testing Config
120 #########
122 # find GTest headers and libs
123 find_package(GTest REQUIRED)
124 include_directories(${GTEST_INCLUDE_DIR})
125 add_library(gtest STATIC IMPORTED)
126 set_target_properties(gtest PROPERTIES IMPORTED_LOCATION "${GTEST_LIBS}")
128 set(HBASE_TEST_LIBS ${HBASE_LIBS} ${GTEST_LIBS})
129 set(HBASE_ASYNC_TEST_LIBS ${HBASE_LIBS} ${GTEST_LIBS} hbase-async)
130 set(HBASE_SYNC_TEST_LIBS ${HBASE_LIBS} ${GTEST_LIBS} hbase-sync)
132 function(ADD_HBASE_ASYNC_TEST TEST_NAME)
133     add_executable(${TEST_NAME} ${TEST_NAME}.cc)
134     target_link_libraries(${TEST_NAME} ${HBASE_ASYNC_TEST_LIBS})
135     add_test(${TEST_NAME} "${EXECUTABLE_OUTPUT_PATH}/${TEST_NAME}")
136 endfunction()
139 function(ADD_HBASE_SYNC_TEST TEST_NAME)
140     add_executable(${TEST_NAME} ${TEST_NAME}.cc)
141     target_link_libraries(${TEST_NAME} ${HBASE_ASYNC_TEST_LIBS})
142     add_test(${TEST_NAME} "${EXECUTABLE_OUTPUT_PATH}/${TEST_NAME}")
143 endfunction()
146 #####
147 # Actual project definition
148 #####
149 add_subdirectory(src/async)
150 add_subdirectory(src/sync)
152 add_subdirectory(src/core)
153 add_subdirectory(src/rpc)
156 add_library(hbase-async SHARED $<TARGET_OBJECTS:hcore> $<TARGET_OBJECTS:hasync>)
157 add_library(hbase-sync SHARED $<TARGET_OBJECTS:hcore> $<TARGET_OBJECTS:hsync>)