8000 Allow to use Boost.Regex with cmake · psteinb/docopt.cpp@8e45a51 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8e45a51

Browse files
committed
Allow to use Boost.Regex with cmake
1 parent cee3d10 commit 8e45a51

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ include(GNUInstallDirs)
88
#============================================================================
99
option(WITH_TESTS "Build tests." OFF)
1010
option(WITH_EXAMPLE "Build example." OFF)
11+
option(USE_BOOST_REGEX "Replace std::regex with Boost.Regex" OFF)
1112

1213
#============================================================================
1314
# Internal compiler options
@@ -52,6 +53,19 @@ if(NOT MSVC)
5253
set_target_properties(docopt_s PROPERTIES OUTPUT_NAME docopt)
5354
endif()
5455

56+
if(USE_BOOST_REGEX)
57+
add_definitions("-DDOCTOPT_USE_BOOST_REGEX")
58+
# This is needed on Linux, where linking a static library into docopt.so
59+
# fails because boost static libs are not compiled with -fPIC
60+
set(Boost_USE_STATIC_LIBS OFF)
61+
find_package(Boost 1.53 REQUIRED COMPONENTS regex)
62+
include_directories(${Boost_INCLUDE_DIRS})
63+
target_link_libraries(docopt ${Boost_LIBRARIES})
64+
if(WITH_STATIC)
65+
target_link_libraries(docopt_s ${Boost_LIBRARIES})
66+
endif()
67+
endif()
68+
5569
#============================================================================
5670
# Examples
5771
#============================================================================

0 commit comments

Comments
 (0)
0