Skip to content

Commit

Permalink
Merge pull request RobotLocomotion#10400 from jamiesnape/cmakelists-c…
Browse files Browse the repository at this point in the history
…leanup-2

Miscellaneous cleanup of CMakeLists.txt
  • Loading branch information
jamiesnape authored Jan 14, 2019
2 parents 266363d + d42f92e commit 8dd7446
Showing 1 changed file with 47 additions and 18 deletions.
65 changes: 47 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ string(FIND "${PROJECT_BINARY_DIR_REALPATH}/" "${PROJECT_SOURCE_DIR_REALPATH}/"
if(STRING_FIND_RESULT_VARIABLE EQUAL 0)
# The --output_base cannot be within the WORKSPACE (a subdirectory of
# PROJECT_SOURCE_DIR), so fallback to the using the same parent directory
# that bazel uses by default for its --output_base.
# that Bazel uses by default for its --output_base.
if(APPLE)
set(BAZEL_OUTPUT_BASE "/var/tmp")
else()
Expand All @@ -245,8 +245,8 @@ else()
set(BAZEL_OUTPUT_BASE "${PROJECT_BINARY_DIR}")
endif()

# Compute the MD5 of the PROJECT_BINARY_DIR rather than the WORKSPACE
# (PROJECT_SOURCE_DIR) to avoid colliding with the directory that bazel uses by
# Compute the MD5 hash of the PROJECT_BINARY_DIR rather than the WORKSPACE
# (PROJECT_SOURCE_DIR) to avoid colliding with the directory that Bazel uses by
# default.
string(MD5 PROJECT_BINARY_DIR_MD5 "${PROJECT_BINARY_DIR_REALPATH}")
set(BAZEL_OUTPUT_BASE
Expand Down Expand Up @@ -297,20 +297,31 @@ if(WITH_MOSEK)
list(APPEND BAZEL_ARGS --config=mosek)
endif()

option(WITH_ROBOTLOCOMOTION_SNOPT "Build with support for SNOPT using the RobotLocomotion/snopt private GitHub repository" OFF)
option(WITH_SNOPT "Build with support for SNOPT using the SNOPT source archive at SNOPT_PATH" OFF)
option(WITH_ROBOTLOCOMOTION_SNOPT
"Build with support for SNOPT using the RobotLocomotion/snopt private GitHub repository"
OFF
)
option(WITH_SNOPT
"Build with support for SNOPT using a SNOPT source archive at SNOPT_PATH"
OFF
)

if(WITH_ROBOTLOCOMOTION_SNOPT AND WITH_SNOPT)
message(FATAL_ERROR
"WITH_SNOPT and WITH_ROBOTLOCOMOTION_SNOPT are mutually exclusive")
"WITH_ROBOTLOCOMOTION_SNOPT and WITH_SNOPT options are mutually exclusive"
)
elseif(WITH_ROBOTLOCOMOTION_SNOPT)
list(APPEND BAZEL_ARGS --config=snopt)
list(APPEND BAZEL_ENV "SNOPT_PATH=git")
elseif(WITH_SNOPT)
list(APPEND BAZEL_ARGS --config=snopt)
set(SNOPT_PATH SNOPT_PATH-NOTFOUND CACHE FILEPATH "Path to SNOPT source archive")
set(SNOPT_PATH SNOPT_PATH-NOTFOUND CACHE FILEPATH
"Path to SNOPT source archive"
)
if(NOT EXISTS "${SNOPT_PATH}")
message(FATAL_ERROR "SNOPT source archive was NOT found at '${SNOPT_PATH}'")
message(FATAL_ERROR
"SNOPT source archive was NOT found at '${SNOPT_PATH}'"
)
endif()
mark_as_advanced(SNOPT_PATH)
list(APPEND BAZEL_ENV "SNOPT_PATH=${SNOPT_PATH}")
Expand Down Expand Up @@ -350,7 +361,9 @@ if(CMAKE_BUILD_TYPE MATCHES "^(Debug|RelWithDebInfo)$")
# SNOPT has restrictions for redistribution given that we are statically
# linking it in.
if(WITH_SNOPT OR WITH_ROBOTLOCOMOTION_SNOPT)
message(WARNING "SNOPT is enabled, thus symbols will STILL be stripped, even in debug mode.")
message(WARNING
"Install configuration ${CMAKE_BUILD_TYPE} will STILL strip symbols because support for SNOPT is enabled"
)
else()
list(INSERT BAZEL_TARGETS_ARGS 0 "--no_strip")
endif()
Expand All @@ -361,12 +374,26 @@ include(ExternalProject)
ExternalProject_Add(drake_cxx_python
SOURCE_DIR "${PROJECT_SOURCE_DIR}"
CONFIGURE_COMMAND :
BUILD_COMMAND ${BAZEL_ENV} "${Bazel_EXECUTABLE}" ${BAZEL_STARTUP_ARGS} build ${BAZEL_ARGS} ${BAZEL_TARGETS}
BUILD_IN_SOURCE 1
BUILD_ALWAYS 1
INSTALL_COMMAND ${BAZEL_ENV} "${Bazel_EXECUTABLE}" ${BAZEL_STARTUP_ARGS} run ${BAZEL_ARGS} ${BAZEL_TARGETS} -- ${BAZEL_TARGETS_ARGS}
USES_TERMINAL_BUILD 1
USES_TERMINAL_INSTALL 1
BUILD_COMMAND
${BAZEL_ENV}
"${Bazel_EXECUTABLE}"
${BAZEL_STARTUP_ARGS}
build
${BAZEL_ARGS}
${BAZEL_TARGETS}
BUILD_IN_SOURCE ON
BUILD_ALWAYS ON
INSTALL_COMMAND
${BAZEL_ENV}
"${Bazel_EXECUTABLE}"
${BAZEL_STARTUP_ARGS}
run
${BAZEL_ARGS}
${BAZEL_TARGETS}
--
${BAZEL_TARGETS_ARGS}
USES_TERMINAL_BUILD ON
USES_TERMINAL_INSTALL ON
)

set(GIT_DIR "${PROJECT_SOURCE_DIR}/.git")
Expand All @@ -375,7 +402,8 @@ set(GIT_REVISION HEAD)
find_package(Git)

if(GIT_FOUND AND EXISTS "${GIT_DIR}")
execute_process(COMMAND "${GIT_EXECUTABLE}" "--git-dir=${GIT_DIR}" rev-parse HEAD
execute_process(COMMAND
"${GIT_EXECUTABLE}" "--git-dir=${GIT_DIR}" rev-parse HEAD
RESULT_VARIABLE GIT_REV_PARSE_RESULT_VARIABLE
OUTPUT_VARIABLE GIT_REV_PARSE_OUTPUT_VARIABLE
OUTPUT_STRIP_TRAILING_WHITESPACE
Expand Down Expand Up @@ -409,7 +437,7 @@ if(WITH_MATLAB)
"-DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_SHARED_LINKER_FLAGS}"
-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}
BINARY_DIR "${PROJECT_BINARY_DIR}/drake_matlab-build"
BUILD_ALWAYS 1
BUILD_ALWAYS ON
)
endif()

Expand Down Expand Up @@ -440,7 +468,8 @@ else()
set(CPACK_DEBIAN_PACKAGE_RELEASE 1)
set(CPACK_DEBIAN_PACKAGE_SECTION contrib/devel)

file(STRINGS "setup/${UNIX_DISTRIBUTION_ID}/binary_distribution/packages-${UNIX_DISTRIBUTION_CODENAME}.txt"
file(STRINGS
"setup/${UNIX_DISTRIBUTION_ID}/binary_distribution/packages-${UNIX_DISTRIBUTION_CODENAME}.txt"
CPACK_DEBIAN_PACKAGE_DEPENDS
)
string(REGEX REPLACE "([a-z0-9\\-]+)=([a-z0-9\\-\\.~]+)" "\\1 (= \\2)"
Expand Down

0 comments on commit 8dd7446

Please sign in to comment.