Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 33026db

Browse files
committed
Added BUILD_SHARED_LIBS option to cmake. If set to "OFF", static library will be generated
for a UNIX build If BUILD_UNIT_TESTS is off, do not search for gtest library, and do not include tests subdirectory
1 parent f6ed17e commit 33026db

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

CMakeLists.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CONFIG_PATH}")
2424
option(BUILD_EXAMPLES "Build tutorials and examples" ON)
2525
option(BUILD_UNIT_TESTS "Build the unit tests" ON)
2626
option(BUILD_TOOLS "Build commandline tools" ON)
27+
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
2728

2829
#############################################################
2930
# Find packages
@@ -85,7 +86,7 @@ elseif( CATKIN_DEVEL_PREFIX OR CATKIN_BUILD_BINARY_PACKAGE)
8586
list(APPEND BEHAVIOR_TREE_EXTERNAL_LIBRARIES ${catkin_LIBRARIES})
8687
set(BUILD_TOOL_INCLUDE_DIRS ${catkin_INCLUDE_DIRS})
8788

88-
else()
89+
elseif(BUILD_UNIT_TESTS)
8990
find_package(GTest)
9091

9192
if(NOT GTEST_FOUND)
@@ -166,7 +167,11 @@ list(APPEND BT_SOURCE
166167

167168
if (UNIX)
168169
list(APPEND BT_SOURCE src/shared_library_UNIX.cpp )
169-
add_library(${BEHAVIOR_TREE_LIBRARY} SHARED ${BT_SOURCE} )
170+
if (BUILD_SHARED_LIBS)
171+
add_library(${BEHAVIOR_TREE_LIBRARY} SHARED ${BT_SOURCE})
172+
else()
173+
add_library(${BEHAVIOR_TREE_LIBRARY} STATIC ${BT_SOURCE})
174+
endif()
170175
endif()
171176

172177
if (WIN32)
@@ -203,7 +208,9 @@ endif()
203208

204209
######################################################
205210
# Test
206-
add_subdirectory(tests)
211+
if (BUILD_UNIT_TESTS)
212+
add_subdirectory(tests)
213+
endif()
207214

208215
######################################################
209216
# INSTALL

0 commit comments

Comments
 (0)