Skip to content

Commit

Permalink
cmake cleanup
Browse files Browse the repository at this point in the history
* use target_include_directories instead of include_directories
* use target_compile_definition for ENABLE_PYTHON_BINDINGS
  • Loading branch information
esquires committed Oct 21, 2018
1 parent 74b9dd8 commit 8cfa91b
Show file tree
Hide file tree
Showing 64 changed files with 89 additions and 43 deletions.
26 changes: 8 additions & 18 deletions CMakeLists.txt
Expand Up @@ -106,16 +106,13 @@ GenerateSetEnv(
set(MSGS_INCLUDE_DIR ${PROJECT_BINARY_DIR}/msgs)
set(PROTO_INCLUDE_DIR ${PROJECT_BINARY_DIR}/src/proto)

include_directories(${SCRIMMAGE_INC_DIR})
include_directories(${MSGS_INCLUDE_DIR})
include_directories(${PROTO_INCLUDE_DIR})

option(EXTERNAL "EXTERNAL" 0)

option(ENABLE_PYTHON_BINDINGS "ENABLE_PYTHON_BINDINGS" ON)
set(PYTHON_MIN_VERSION "2.7" CACHE STRING "Minimum Python version for building")
if (ENABLE_PYTHON_BINDINGS)
add_definitions(-DENABLE_PYTHON_BINDINGS=1)

# Find Python
#The order of the followin find_package calls is important!
Expand All @@ -127,22 +124,26 @@ if (ENABLE_PYTHON_BINDINGS)
message(STATUS "PYTHON_INCLUDE_DIRS: ${PYTHON_INCLUDE_DIRS}")

set(PYTHON_FOUND TRUE)
include_directories("${PYTHON_INCLUDE_DIRS}")

# We have already found the python libs and modules, so tell pybind11 to not
# search for the python interpreter and libraries again.
set(PYTHONLIBS_FOUND TRUE)
set(PYTHON_MODULE_EXTENSION TRUE)
find_package(pybind11 REQUIRED)
include_directories(${pybind11_INCLUDE_DIRS})
set(PYBIND11_INCLUDE_DIRS ${pybind11_INCLUDE_DIRS})

add_library(scrimmage-python INTERFACE)
target_include_directories(scrimmage-python INTERFACE ${PYTHON_INCLUDE_DIRS} ${pybind11_INCLUDE_DIRS})
target_include_directories(scrimmage-python
SYSTEM INTERFACE ${PYTHON_INCLUDE_DIRS})
target_include_directories(scrimmage-python
INTERFACE ${pybind11_INCLUDE_DIRS})
target_compile_definitions(scrimmage-python
INTERFACE -DENABLE_PYTHON_BINDINGS=1)
target_link_libraries(scrimmage-python INTERFACE ${PYTHON_LIBRARIES})
install(TARGETS scrimmage-python EXPORT ${PROJECT_NAME}-targets)
else()
add_definitions(-DENABLE_PYTHON_BINDINGS=0)
target_compile_definitions(scrimmage-python
INTERFACE -DENABLE_PYTHON_BINDINGS=0)
endif()

########################################################
Expand All @@ -168,7 +169,6 @@ else()
set(PROTOBUF_LIBRARIES "${PROTOBUF_LIBS}")
set(PROTOBUF_INCLUDE_DIRS "${PROTOBUF_INCLUDE}")
endif()
include_directories(${PROTOBUF_INCLUDE_DIRS})
set(PROTOBUF_INCLUDE ${PROTOBUF_INCLUDE_DIRS})

########################################################
Expand All @@ -187,7 +187,6 @@ endif()
########################################################
find_package (GeographicLib REQUIRED)
add_definitions (${GeographicLib_DEFINITIONS})
include_directories (${GeographicLib_INCLUDE_DIRS})

########################################################
# Find JSBSim
Expand All @@ -196,7 +195,6 @@ if (NOT APPLE)
find_package(JSBSIM REQUIRED)
string(FIND "${JSBSIM_INCLUDE_DIRS}" "NOTFOUND" POS)
if (JSBSIM_FOUND AND (POS EQUAL -1))
include_directories(SYSTEM ${JSBSIM_INCLUDE_DIR})
add_definitions(-DENABLE_JSBSIM=1)
else()
add_definitions(-DENABLE_JSBSIM=0)
Expand Down Expand Up @@ -256,7 +254,6 @@ if (NOT Eigen3_FOUND)
set(EIGEN3_INCLUDE_DIR ${EIGEN_PKGCONFIG_INCLUDE_DIRS})
message("Found Eigen with pkg-config, EIGEN3_INCLUDE_DIR: ${EIGEN3_INCLUDE_DIR}")
endif()
include_directories(${EIGEN3_INCLUDE_DIR})

########################################################
# Find Boost
Expand Down Expand Up @@ -360,13 +357,6 @@ if (NOT DEFINED CMAKE_TOOLCHAIN_FILE AND BUILD_TESTS)
# the gtest and gtest_main targets.
add_subdirectory(${PROJECT_BINARY_DIR}/googletest-src
${PROJECT_BINARY_DIR}/googletest-build)

# The gtest/gtest_main targets carry header search path
# dependencies automatically when using CMake 2.8.11 or
# later. Otherwise we have to add them here ourselves.
if (CMAKE_VERSION VERSION_LESS 2.8.11)
include_directories("${gtest_SOURCE_DIR}/include")
endif()
endif()

add_subdirectory(test)
Expand Down
1 change: 0 additions & 1 deletion cmake/Modules/project-config.cmake.in
Expand Up @@ -24,7 +24,6 @@ endif()
set(SCRIMMAGE_LIBRARIES "@PROJECT_LIBS@")
set(SCRIMMAGE_VIEWER_LIB "scrimmage-viewer")
set(SCRIMMAGE_PLUGINS "@PROJECT_PLUGINS@")
set(SCRIMMAGE_ENABLE_PYTHON_BINDINGS "@ENABLE_PYTHON_BINDINGS@")

###############################################################################
# Include references to the important 3rd-party libraries and utilities that
Expand Down
11 changes: 9 additions & 2 deletions src/CMakeLists.txt
Expand Up @@ -57,6 +57,11 @@ target_link_libraries(${LIBRARY_NAME}
Boost::thread
)

if (ENABLE_PYTHON_BINDINGS)
target_link_libraries(
${LIBRARY_NAME} PRIVATE scrimmage-python)
endif()

SET (_soversion ${LIB_MAJOR}.${LIB_MINOR}.${LIB_RELEASE})

set_target_properties(
Expand All @@ -68,8 +73,10 @@ set_target_properties(

target_include_directories(${LIBRARY_NAME}
PUBLIC
"$<INSTALL_INTERFACE:include;${EIGEN3_INCLUDE_DIR};${GeographicLib_INCLUDE_DIRS}>"
"$<BUILD_INTERFACE:${SCRIMMAGE_INC_DIR};${EIGEN3_INCLUDE_DIR};${GeographicLib_INCLUDE_DIRS}>"
${EIGEN3_INCLUDE_DIR}
${GeographicLib_INCLUDE_DIRS}
"$<INSTALL_INTERFACE:include>"
"$<BUILD_INTERFACE:${SCRIMMAGE_INC_DIR}>"
)

install(TARGETS ${LIBRARY_NAME}
Expand Down
1 change: 1 addition & 0 deletions src/plugins/autonomy/ArduPilot/CMakeLists.txt
Expand Up @@ -19,6 +19,7 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED
)

TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
scrimmage-core
Multirotor_plugin
)

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/autonomy/AuctionAssign/CMakeLists.txt
Expand Up @@ -15,7 +15,7 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED

TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
scrimmage-msgs
${SCRIMMAGE_LIBS}
scrimmage-core
)

SET (_soversion ${LIB_MAJOR}.${LIB_MINOR}.${LIB_RELEASE})
Expand Down
1 change: 1 addition & 0 deletions src/plugins/autonomy/AutonomyExecutor/CMakeLists.txt
Expand Up @@ -13,6 +13,7 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED
)

TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
scrimmage-core
)

SET (_soversion ${LIB_MAJOR}.${LIB_MINOR}.${LIB_RELEASE})
Expand Down
1 change: 1 addition & 0 deletions src/plugins/autonomy/AvoidEntityMS/CMakeLists.txt
Expand Up @@ -13,6 +13,7 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED
)

TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
scrimmage-core
)

SET (_soversion ${LIB_MAJOR}.${LIB_MINOR}.${LIB_RELEASE})
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/autonomy/Boids/CMakeLists.txt
Expand Up @@ -14,7 +14,7 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED


TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
${SCRIMMAGE_LIBS}
scrimmage-core
)

SET (_soversion ${LIB_MAJOR}.${LIB_MINOR}.${LIB_RELEASE})
Expand Down
1 change: 1 addition & 0 deletions src/plugins/autonomy/Control3D/CMakeLists.txt
Expand Up @@ -14,6 +14,7 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED


TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
scrimmage-core
)

SET (_soversion ${LIB_MAJOR}.${LIB_MINOR}.${LIB_RELEASE})
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/autonomy/FlightGearMultiplayer/CMakeLists.txt
@@ -1,6 +1,6 @@
# TODO Find fgms code. include_directories() to point at the ./fgms/src
# directory. Also, get the libraries that are built by fgms and allow them to
# be used in the target_link_libraries below:
# be used in the target_link_libraries below: scrimmage-core scrimmage-core
find_package(FGMS QUIET)
if(NOT FGMS_FOUND)
return()
Expand Down Expand Up @@ -28,6 +28,7 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED
)

TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
scrimmage-core
${FGMS_LIBRARIES}
)

Expand Down
3 changes: 2 additions & 1 deletion src/plugins/autonomy/GraphvizFSM/CMakeLists.txt
Expand Up @@ -13,7 +13,8 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED
)

TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
${Boost_LIBRARIES}
scrimmage-core
scrimmage-boost
)

SET (_soversion ${LIB_MAJOR}.${LIB_MINOR}.${LIB_RELEASE})
Expand Down
1 change: 1 addition & 0 deletions src/plugins/autonomy/JoystickAutonomy/CMakeLists.txt
Expand Up @@ -14,6 +14,7 @@ if (NOT APPLE)
)

TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
scrimmage-core
JoystickController_plugin
)

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/autonomy/MOOSAutonomy/CMakeLists.txt
Expand Up @@ -92,11 +92,11 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED
# This is necessary when doing parallel builds (e.g. make -j8)

TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
scrimmage-core
${MOOS_LIBRARIES}
contacts
mbutil
geometry

)

SET (_soversion ${LIB_MAJOR}.${LIB_MINOR}.${LIB_RELEASE})
Expand Down
1 change: 1 addition & 0 deletions src/plugins/autonomy/MotorSchemas/CMakeLists.txt
Expand Up @@ -14,6 +14,7 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED


TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
scrimmage-core
)

SET (_soversion ${LIB_MAJOR}.${LIB_MINOR}.${LIB_RELEASE})
Expand Down
1 change: 1 addition & 0 deletions src/plugins/autonomy/Predator/CMakeLists.txt
Expand Up @@ -14,6 +14,7 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED


TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
scrimmage-core
)

SET (_soversion ${LIB_MAJOR}.${LIB_MINOR}.${LIB_RELEASE})
Expand Down
5 changes: 2 additions & 3 deletions src/plugins/autonomy/PyAutonomy/CMakeLists.txt
Expand Up @@ -15,9 +15,8 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED
# This is necessary when doing parallel builds (e.g. make -j8)

TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
${SCRIMMAGE_LIBS}
${Boost_LIBRARIES}
${PYTHON_LIBRARIES}
scrimmage-core
scrimmage-python
)

SET (_soversion ${LIB_MAJOR}.${LIB_MINOR}.${LIB_RELEASE})
Expand Down
5 changes: 0 additions & 5 deletions src/plugins/autonomy/RLConsensus/CMakeLists.txt
@@ -1,8 +1,3 @@
if(NOT GRPC_FOUND)
message("GRPC not found. Not building RLSimple.")
return()
endif()

#--------------------------------------------------------
# Library Creation
#--------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src/plugins/autonomy/ROSAutonomy/CMakeLists.txt
Expand Up @@ -18,6 +18,7 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED


TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
scrimmage-core
${catkin_LIBRARIES}
)

Expand Down
1 change: 1 addition & 0 deletions src/plugins/autonomy/ROSControl/CMakeLists.txt
Expand Up @@ -18,6 +18,7 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED


TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
scrimmage-core
${catkin_LIBRARIES}
)

Expand Down
1 change: 0 additions & 1 deletion src/plugins/autonomy/Straight/CMakeLists.txt
Expand Up @@ -14,7 +14,6 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED


TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
${SCRIMMAGE_LIBS}
${OpenCV_LIBRARIES}
Boundary_plugin
scrimmage-core
Expand Down
1 change: 1 addition & 0 deletions src/plugins/autonomy/TrailMS/CMakeLists.txt
Expand Up @@ -13,6 +13,7 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED
)

TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
scrimmage-core
)

SET (_soversion ${LIB_MAJOR}.${LIB_MINOR}.${LIB_RELEASE})
Expand Down
Expand Up @@ -13,6 +13,7 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED
)

TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
scrimmage-core
)


Expand Down
1 change: 1 addition & 0 deletions src/plugins/autonomy/WaypointGenerator/CMakeLists.txt
Expand Up @@ -13,6 +13,7 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED
)

TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
scrimmage-core
)

SET (_soversion ${LIB_MAJOR}.${LIB_MINOR}.${LIB_RELEASE})
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/autonomy/follow/CMakeLists.txt
Expand Up @@ -14,7 +14,7 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED


TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
${SCRIMMAGE_LIBS}
scrimmage-core
)

SET (_soversion ${LIB_MAJOR}.${LIB_MINOR}.${LIB_RELEASE})
Expand Down
Expand Up @@ -14,6 +14,7 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED


TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
scrimmage-core
)

SET (_soversion ${LIB_MAJOR}.${LIB_MINOR}.${LIB_RELEASE})
Expand Down
1 change: 1 addition & 0 deletions src/plugins/controller/DirectController/CMakeLists.txt
Expand Up @@ -13,6 +13,7 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED
)

TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
scrimmage-core
)

SET (_soversion ${LIB_MAJOR}.${LIB_MINOR}.${LIB_RELEASE})
Expand Down
Expand Up @@ -14,6 +14,7 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED


TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
scrimmage-core
)

SET (_soversion ${LIB_MAJOR}.${LIB_MINOR}.${LIB_RELEASE})
Expand Down
Expand Up @@ -14,6 +14,7 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED


TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
scrimmage-core
)

SET (_soversion ${LIB_MAJOR}.${LIB_MINOR}.${LIB_RELEASE})
Expand Down
Expand Up @@ -18,6 +18,7 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED ${SRCS})


TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
scrimmage-core
${catkin_LIBRARIES}
)

Expand Down
Expand Up @@ -13,6 +13,7 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED
)

TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
scrimmage-core
Multirotor_plugin
)

Expand Down
Expand Up @@ -13,6 +13,7 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED
)

TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
scrimmage-core
Multirotor_plugin
)

Expand Down
Expand Up @@ -14,6 +14,7 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED


TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
scrimmage-core
)

SET (_soversion ${LIB_MAJOR}.${LIB_MINOR}.${LIB_RELEASE})
Expand Down
Expand Up @@ -19,6 +19,7 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED
)

TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
scrimmage-core
${catkin_LIBRARIES}
)

Expand Down
Expand Up @@ -14,6 +14,7 @@ ADD_LIBRARY(${LIBRARY_NAME} SHARED


TARGET_LINK_LIBRARIES(${LIBRARY_NAME}
scrimmage-core
)

SET (_soversion ${LIB_MAJOR}.${LIB_MINOR}.${LIB_RELEASE})
Expand Down

0 comments on commit 8cfa91b

Please sign in to comment.