-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add support for gtest if testing is enabled. #451
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
Changes from 1 commit
c35b27d
2befa51
48f6bc8
405426a
cd1255a
12f9519
4198148
0d56bb1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1078,6 +1078,43 @@ function(ROOT_ADD_TEST test) | |
|
|
||
| endfunction() | ||
|
|
||
| #---------------------------------------------------------------------------- | ||
| # ROOT_PATH_TO_STRING( <variable> path PATH_SEPARATOR_REPLACEMENT replacement ) | ||
| # | ||
| # Mangle the path to a string. | ||
| #---------------------------------------------------------------------------- | ||
| function(ROOT_PATH_TO_STRING resultvar path) | ||
| # FIXME: Copied and modified from ROOTTEST_TARGETNAME_FROM_FILE. We should find a common place for that code. | ||
| # FIXME: ROOTTEST_TARGETNAME_FROM_FILE could be replaced by just a call to string(MAKE_C_IDENTIFIER)... | ||
| CMAKE_PARSE_ARGUMENTS(ARG "" "" "PATH_SEPARATOR_REPLACEMENT" ${ARGN}) | ||
|
|
||
| set(sep_replacement "") | ||
| if (ARG_PATH_SEPARATOR_REPLACEMENT) | ||
| set(sep_replacement ${ARG_PATH_SEPARATOR_REPLACEMENT}) | ||
| endif() | ||
|
|
||
| get_filename_component(realfp ${path} ABSOLUTE) | ||
| get_filename_component(filename_we ${path} NAME_WE) | ||
|
|
||
| string(REPLACE "${CMAKE_SOURCE_DIR}" "" relativepath ${realfp}) | ||
| string(REPLACE "${path}" "" relativepath ${relativepath}) | ||
|
|
||
| string(MAKE_C_IDENTIFIER ${relativepath}${filename_we} mangledname) | ||
| string(REPLACE "_" "${sep_replacement}" mangledname ${mangledname}) | ||
|
|
||
| set(${resultvar} "${mangledname}" PARENT_SCOPE) | ||
| endfunction(ROOT_PATH_TO_STRING) | ||
|
|
||
| #---------------------------------------------------------------------------- | ||
| # ROOT_ADD_UNITTEST_SUBDIRECTORY( <name> LIBRARIES) | ||
| #---------------------------------------------------------------------------- | ||
| function(ROOT_ADD_UNITTEST_SUBDIRECTORY subdir) | ||
| ROOT_GLOB_FILES(test_files ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}/*.cxx) | ||
| # Get the component from the path. Eg. core to form coreTests test suite name. | ||
| ROOT_PATH_TO_STRING(test_name ${CMAKE_CURRENT_SOURCE_DIR}/Tests/) | ||
| ROOT_ADD_GTEST(${test_name} ${test_files} ${ARGN}) | ||
| endfunction() | ||
|
|
||
| #---------------------------------------------------------------------------- | ||
| # function ROOT_ADD_GTEST(<testsuite> source1 source2... LIBRARIES) | ||
| # | ||
|
|
@@ -1091,21 +1128,11 @@ function(ROOT_ADD_GTEST test_suite) | |
| # FIXME: For better coherence we could restrict the libraries the test suite could link | ||
| # against. For example, tests in Core should link only against libCore. This could be tricky | ||
| # to implement because some ROOT components create more than one library. | ||
| ROOT_EXECUTABLE(${test_suite} ${source_files} LIBRARIES ${ARG_LIBRARIES}) | ||
| ROOT_EXECUTABLE(${test_suite} NOINSTALL ${source_files} LIBRARIES ${ARG_LIBRARIES}) | ||
|
Member
Author
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. @peremato, this is the problematic line that puts the test binary in the ROOT install dir.
Contributor
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. The default output directory for binaries is controlled by this variable CMAKE_RUNTIME_OUTPUT_DIRECTORY. On possibility is to clear the variable before calling ROOT_EXECUTABLE(...) or setting the specific target property afterwards with |
||
| target_link_libraries(${test_suite} gtest gtest_main gmock gmock_main) | ||
|
|
||
| # Mangle the path to the test name. | ||
| # FIXME: Copied and modified from ROOTTEST_TARGETNAME_FROM_FILE. We should find a common place for that code. | ||
| set(filename ${test_suite}) | ||
| get_filename_component(realfp ${filename} ABSOLUTE) | ||
| get_filename_component(filename_we ${filename} NAME_WE) | ||
|
|
||
| string(REPLACE "${CMAKE_SOURCE_DIR}" "" relativepath ${realfp}) | ||
| string(REPLACE "${filename}" "" relativepath ${relativepath}) | ||
|
|
||
| string(REPLACE "/" "-" targetname ${relativepath}${filename_we}) | ||
|
|
||
| ROOT_ADD_TEST(gtest${targetname} COMMAND ${test_suite}) | ||
| ROOT_PATH_TO_STRING(mangled_name ${test_suite} PATH_SEPARATOR_REPLACEMENT "-") | ||
| ROOT_ADD_TEST(gtest${mangled_name} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${test_suite}) | ||
| endfunction() | ||
|
|
||
|
|
||
|
|
||
This file was deleted.
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.
Is that
LIBRARIES <lib1> <lib2>or how does that work? Could you clarify in the comment/doc?