Skip to content

Commit

Permalink
build(cmake, build_config): define build config macros
Browse files Browse the repository at this point in the history
  • Loading branch information
lotem committed Jan 16, 2021
1 parent db72474 commit ac37dfc
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ endif()
set(BOOST_COMPONENTS filesystem regex system)

if(BOOST_USE_SIGNALS2)
add_definitions("-DBOOST_SIGNALS2")
set(RIME_BOOST_SIGNALS2 1)
else()
set(BOOST_COMPONENTS ${BOOST_COMPONENTS} signals)
endif()
Expand Down Expand Up @@ -89,7 +89,7 @@ if(ENABLE_LOGGING)
add_definitions(-DGOOGLE_GLOG_DLL_DECL=)
endif()

add_definitions(-DRIME_ENABLE_LOGGING)
set(RIME_ENABLE_LOGGING 1)

endif()

Expand Down Expand Up @@ -134,6 +134,11 @@ else()
message(WARNING "X11/keysym.h not found.")
endif()

configure_file(
"${PROJECT_SOURCE_DIR}/src/rime/build_config.h.in"
"${PROJECT_BINARY_DIR}/src/rime/build_config.h")

include_directories(${PROJECT_BINARY_DIR}/src)
include_directories(${PROJECT_SOURCE_DIR}/src)
include_directories(${PROJECT_SOURCE_DIR}/thirdparty/include)
link_directories(${PROJECT_SOURCE_DIR}/thirdparty/lib)
Expand Down
11 changes: 11 additions & 0 deletions src/rime/build_config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//
// Copyright RIME Developers
// Distributed under the BSD License
//
#ifndef RIME_BUILD_CONFIG_H_
#define RIME_BUILD_CONFIG_H_

#cmakedefine RIME_BOOST_SIGNALS2
#cmakedefine RIME_ENABLE_LOGGING

#endif // RIME_BUILD_CONFIG_H_
6 changes: 4 additions & 2 deletions src/rime/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#ifndef RIME_COMMON_H_
#define RIME_COMMON_H_

#include <rime/build_config.h>

#include <functional>
#include <list>
#include <map>
Expand All @@ -20,7 +22,7 @@
#include <vector>
#include <boost/optional.hpp>
#define BOOST_BIND_NO_PLACEHOLDERS
#ifdef BOOST_SIGNALS2
#ifdef RIME_BOOST_SIGNALS2
#include <boost/signals2/connection.hpp>
#include <boost/signals2/signal.hpp>
#else
Expand Down Expand Up @@ -79,7 +81,7 @@ inline an<T> New(Args&&... args) {
return std::make_shared<T>(std::forward<Args>(args)...);
}

#ifdef BOOST_SIGNALS2
#ifdef RIME_BOOST_SIGNALS2
using boost::signals2::connection;
using boost::signals2::signal;
#else
Expand Down
3 changes: 3 additions & 0 deletions src/rime/lever/deployment_tasks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
//
// 2011-12-10 GONG Chen <[email protected]>
//

#include <rime/build_config.h>

#include <algorithm>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
Expand Down
2 changes: 2 additions & 0 deletions src/rime/setup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// 2011-10-02 GONG Chen <[email protected]>
//

#include <rime/build_config.h>

#ifdef RIME_ENABLE_LOGGING
#include <glog/logging.h>
#endif // RIME_ENABLE_LOGGING
Expand Down

0 comments on commit ac37dfc

Please sign in to comment.