Skip to content

Commit ac37dfc

Browse files
committed
build(cmake, build_config): define build config macros
1 parent db72474 commit ac37dfc

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

CMakeLists.txt

+7-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ endif()
6161
set(BOOST_COMPONENTS filesystem regex system)
6262

6363
if(BOOST_USE_SIGNALS2)
64-
add_definitions("-DBOOST_SIGNALS2")
64+
set(RIME_BOOST_SIGNALS2 1)
6565
else()
6666
set(BOOST_COMPONENTS ${BOOST_COMPONENTS} signals)
6767
endif()
@@ -89,7 +89,7 @@ if(ENABLE_LOGGING)
8989
add_definitions(-DGOOGLE_GLOG_DLL_DECL=)
9090
endif()
9191

92-
add_definitions(-DRIME_ENABLE_LOGGING)
92+
set(RIME_ENABLE_LOGGING 1)
9393

9494
endif()
9595

@@ -134,6 +134,11 @@ else()
134134
message(WARNING "X11/keysym.h not found.")
135135
endif()
136136

137+
configure_file(
138+
"${PROJECT_SOURCE_DIR}/src/rime/build_config.h.in"
139+
"${PROJECT_BINARY_DIR}/src/rime/build_config.h")
140+
141+
include_directories(${PROJECT_BINARY_DIR}/src)
137142
include_directories(${PROJECT_SOURCE_DIR}/src)
138143
include_directories(${PROJECT_SOURCE_DIR}/thirdparty/include)
139144
link_directories(${PROJECT_SOURCE_DIR}/thirdparty/lib)

src/rime/build_config.h.in

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//
2+
// Copyright RIME Developers
3+
// Distributed under the BSD License
4+
//
5+
#ifndef RIME_BUILD_CONFIG_H_
6+
#define RIME_BUILD_CONFIG_H_
7+
8+
#cmakedefine RIME_BOOST_SIGNALS2
9+
#cmakedefine RIME_ENABLE_LOGGING
10+
11+
#endif // RIME_BUILD_CONFIG_H_

src/rime/common.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#ifndef RIME_COMMON_H_
88
#define RIME_COMMON_H_
99

10+
#include <rime/build_config.h>
11+
1012
#include <functional>
1113
#include <list>
1214
#include <map>
@@ -20,7 +22,7 @@
2022
#include <vector>
2123
#include <boost/optional.hpp>
2224
#define BOOST_BIND_NO_PLACEHOLDERS
23-
#ifdef BOOST_SIGNALS2
25+
#ifdef RIME_BOOST_SIGNALS2
2426
#include <boost/signals2/connection.hpp>
2527
#include <boost/signals2/signal.hpp>
2628
#else
@@ -79,7 +81,7 @@ inline an<T> New(Args&&... args) {
7981
return std::make_shared<T>(std::forward<Args>(args)...);
8082
}
8183

82-
#ifdef BOOST_SIGNALS2
84+
#ifdef RIME_BOOST_SIGNALS2
8385
using boost::signals2::connection;
8486
using boost::signals2::signal;
8587
#else

src/rime/lever/deployment_tasks.cc

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
//
55
// 2011-12-10 GONG Chen <chen.sst@gmail.com>
66
//
7+
8+
#include <rime/build_config.h>
9+
710
#include <algorithm>
811
#include <boost/algorithm/string.hpp>
912
#include <boost/filesystem.hpp>

src/rime/setup.cc

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
// 2011-10-02 GONG Chen <chen.sst@gmail.com>
66
//
77

8+
#include <rime/build_config.h>
9+
810
#ifdef RIME_ENABLE_LOGGING
911
#include <glog/logging.h>
1012
#endif // RIME_ENABLE_LOGGING

0 commit comments

Comments
 (0)