-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix static builds and optimize test compilation #1343
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
284c8ad
Move tests
azeey cbe4600
Fix static builds and optimize test compilation
azeey 02dac75
Use the STATIC_DEFINE flag
azeey 5437306
Define URDFDOM_STATIC only when using the internal URDF
azeey 639d070
Merge branch 'sdf12' into fix_static
azeey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,9 @@ ign_get_libsources_and_unittests(sources gtest_sources) | |
# Add the source file auto-generated into the build folder from sdf/CMakeLists.txt | ||
list(APPEND sources EmbeddedSdf.cc) | ||
|
||
# Use interface library to deduplicate cmake logic for URDF linking | ||
add_library(using_parser_urdf INTERFACE) | ||
# When using the internal URDF parser, we build its sources with the core library | ||
if (USE_INTERNAL_URDF) | ||
set(sources ${sources} | ||
set(urdf_internal_sources | ||
urdf/urdf_parser/model.cpp | ||
urdf/urdf_parser/link.cpp | ||
urdf/urdf_parser/joint.cpp | ||
|
@@ -17,59 +16,48 @@ if (USE_INTERNAL_URDF) | |
urdf/urdf_parser/urdf_model_state.cpp | ||
urdf/urdf_parser/urdf_sensor.cpp | ||
urdf/urdf_parser/world.cpp) | ||
target_include_directories(using_parser_urdf INTERFACE | ||
${CMAKE_CURRENT_SOURCE_DIR}/urdf) | ||
if (WIN32) | ||
target_compile_definitions(using_parser_urdf INTERFACE -D_USE_MATH_DEFINES) | ||
endif() | ||
else() | ||
target_link_libraries(using_parser_urdf INTERFACE | ||
IgnURDFDOM::IgnURDFDOM) | ||
set(sources ${sources} ${urdf_internal_sources}) | ||
endif() | ||
|
||
if (BUILD_TESTING) | ||
# Build this test file only if Ignition Tools is installed. | ||
if (NOT IGN_PROGRAM) | ||
list(REMOVE_ITEM gtest_sources ign_TEST.cc) | ||
endif() | ||
ign_create_core_library(SOURCES ${sources} | ||
CXX_STANDARD 17 | ||
LEGACY_PROJECT_PREFIX SDFormat | ||
) | ||
|
||
# Skip tests that don't work on Windows | ||
if (WIN32) | ||
list(REMOVE_ITEM gtest_sources Converter_TEST.cc) | ||
list(REMOVE_ITEM gtest_sources FrameSemantics_TEST.cc) | ||
list(REMOVE_ITEM gtest_sources ParamPassing_TEST.cc) | ||
list(REMOVE_ITEM gtest_sources Utils_TEST.cc) | ||
list(REMOVE_ITEM gtest_sources XmlUtils_TEST.cc) | ||
list(REMOVE_ITEM gtest_sources parser_urdf_TEST.cc) | ||
target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME} | ||
PUBLIC | ||
ignition-math${IGN_MATH_VER}::ignition-math${IGN_MATH_VER} | ||
ignition-utils${IGN_UTILS_VER}::ignition-utils${IGN_UTILS_VER} | ||
PRIVATE | ||
TINYXML2::TINYXML2) | ||
|
||
if (USE_INTERNAL_URDF) | ||
target_include_directories(${PROJECT_LIBRARY_TARGET_NAME} PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR}/urdf) | ||
if (WIN32) | ||
target_compile_definitions(${PROJECT_LIBRARY_TARGET_NAME} PRIVATE -D_USE_MATH_DEFINES) | ||
endif() | ||
else() | ||
target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME} PRIVATE | ||
IgnURDFDOM::IgnURDFDOM) | ||
endif() | ||
|
||
ign_build_tests( | ||
TYPE UNIT | ||
SOURCES ${gtest_sources} | ||
INCLUDE_DIRS | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
${PROJECT_SOURCE_DIR}/test | ||
) | ||
if (WIN32 AND USE_INTERNAL_URDF) | ||
target_compile_definitions(${PROJECT_LIBRARY_TARGET_NAME} PRIVATE URDFDOM_STATIC) | ||
endif() | ||
|
||
if (TARGET UNIT_Converter_TEST) | ||
target_link_libraries(UNIT_Converter_TEST | ||
TINYXML2::TINYXML2) | ||
target_sources(UNIT_Converter_TEST PRIVATE | ||
Converter.cc | ||
EmbeddedSdf.cc | ||
XmlUtils.cc) | ||
endif() | ||
target_include_directories(${PROJECT_LIBRARY_TARGET_NAME} | ||
PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
|
||
if (TARGET UNIT_FrameSemantics_TEST) | ||
target_sources(UNIT_FrameSemantics_TEST PRIVATE FrameSemantics.cc Utils.cc) | ||
target_link_libraries(UNIT_FrameSemantics_TEST TINYXML2::TINYXML2) | ||
if (BUILD_TESTING) | ||
# Build this test file only if Ignition Tools is installed. | ||
if (NOT IGN_PROGRAM) | ||
list(REMOVE_ITEM gtest_sources ign_TEST.cc) | ||
endif() | ||
|
||
if (TARGET UNIT_ParamPassing_TEST) | ||
target_link_libraries(UNIT_ParamPassing_TEST | ||
TINYXML2::TINYXML2 | ||
using_parser_urdf) | ||
target_sources(UNIT_ParamPassing_TEST PRIVATE | ||
add_library(library_for_tests OBJECT | ||
Converter.cc | ||
EmbeddedSdf.cc | ||
FrameSemantics.cc | ||
|
@@ -78,53 +66,45 @@ if (BUILD_TESTING) | |
Utils.cc | ||
XmlUtils.cc | ||
parser.cc | ||
parser_urdf.cc) | ||
endif() | ||
parser_urdf.cc | ||
) | ||
|
||
if (TARGET UNIT_Utils_TEST) | ||
target_sources(UNIT_Utils_TEST PRIVATE Utils.cc) | ||
target_link_libraries(UNIT_Utils_TEST TINYXML2::TINYXML2) | ||
if (USE_INTERNAL_URDF) | ||
target_sources(library_for_tests PRIVATE ${urdf_internal_sources}) | ||
endif() | ||
|
||
if (TARGET UNIT_XmlUtils_TEST) | ||
target_link_libraries(UNIT_XmlUtils_TEST | ||
TINYXML2::TINYXML2) | ||
target_sources(UNIT_XmlUtils_TEST PRIVATE XmlUtils.cc) | ||
endif() | ||
# Link against the publically and privately linked libraries of the core library | ||
target_link_libraries(library_for_tests | ||
$<TARGET_PROPERTY:${PROJECT_LIBRARY_TARGET_NAME},LINK_LIBRARIES> | ||
) | ||
|
||
if (TARGET UNIT_parser_urdf_TEST) | ||
target_link_libraries(UNIT_parser_urdf_TEST | ||
TINYXML2::TINYXML2 | ||
using_parser_urdf) | ||
target_sources(UNIT_parser_urdf_TEST PRIVATE | ||
SDFExtension.cc | ||
XmlUtils.cc | ||
parser_urdf.cc) | ||
endif() | ||
endif() | ||
# Use the include flags from the core library | ||
target_include_directories(library_for_tests PUBLIC | ||
$<TARGET_PROPERTY:${PROJECT_LIBRARY_TARGET_NAME},INCLUDE_DIRECTORIES> | ||
) | ||
|
||
ign_create_core_library(SOURCES ${sources} | ||
CXX_STANDARD 17 | ||
LEGACY_PROJECT_PREFIX SDFormat | ||
# Use the private compile flags from the core library. Also set IGNITION_SDFORMAT_STATIC_DEFINE to avoid | ||
# inconsistent linkage issues on windows. Setting the define will cause the SDFORMAT_VISIBLE/SDFORMAT_HIDDEN macros | ||
# to expand to nothing when building a static library | ||
target_compile_definitions(library_for_tests PUBLIC | ||
$<TARGET_PROPERTY:${PROJECT_LIBRARY_TARGET_NAME},COMPILE_DEFINITIONS> | ||
-DIGNITION_SDFORMAT_STATIC_DEFINE | ||
) | ||
|
||
target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME} | ||
PUBLIC | ||
ignition-math${IGN_MATH_VER}::ignition-math${IGN_MATH_VER} | ||
ignition-utils${IGN_UTILS_VER}::ignition-utils${IGN_UTILS_VER} | ||
PRIVATE | ||
TINYXML2::TINYXML2 | ||
using_parser_urdf) | ||
ign_build_tests( | ||
TYPE UNIT | ||
SOURCES ${gtest_sources} | ||
INCLUDE_DIRS | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
${PROJECT_SOURCE_DIR}/test | ||
LIB_DEPS | ||
library_for_tests | ||
TEST_LIST | ||
test_targets | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I don't think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oops. I saw this right after I merged. See #1347. |
||
) | ||
|
||
if (WIN32) | ||
target_compile_definitions(${PROJECT_LIBRARY_TARGET_NAME} PRIVATE URDFDOM_STATIC) | ||
endif() | ||
|
||
target_include_directories(${PROJECT_LIBRARY_TARGET_NAME} | ||
PRIVATE | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
) | ||
|
||
if(NOT WIN32) | ||
add_subdirectory(cmd) | ||
endif() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: spelling