BUILD_BYPRODUCTS and dependency cycle for cmake + ninja + googletest + ExternalProject_Add -


attempting use external project build google test so.

   # add googletest externalproject_add( googletest     git_repository https://github.com/google/googletest.git      # don't need run update command. takes time     # , version d/l shoudl fine     cmake_args = "-dgtest_disable_pthreads=1"      # don't run update     update_command ""      # disable install step     install_command ""     # build_byproducts googletest-prefix/src/googletest-stamp/googletest-gitinfo.txt    # build_byproducts googletest-prefix/tmp/googletest-cfgcmd.txt     build_byproducts "googletest-prefix/src/googletest-build/googlemock/libgmock_main.a"     ) # include dirs googletest framework externalproject_get_property(googletest source_dir) set(gtest_include_dirs    ${source_dir}/googlemock/include    ${source_dir}/googletest/include    )  # create library target gmock main, used create # test executables externalproject_get_property(googletest binary_dir) set(gtest_library_path ${binary_dir}/googlemock/libgmock_main.a) set(gtest_library gmock_main) add_library(${gtest_library} unknown imported) set_property(target ${gtest_library} property imported_location ${gtest_library_path}) add_dependencies(${gtest_library} googletest) 

with ninja generator below warning.

 policy cmp0058 not set: ninja requires custom command byproducts   explicit.  run "cmake --help-policy cmp0058" policy details.  use   cmake_policy command set policy , suppress warning.    project specifies custom command depends on files in build tree   not specified output or byproducts of   add_custom_command or add_custom_target:     googletest-prefix/src/googletest-stamp/googletest-gitinfo.txt    googletest-prefix/tmp/googletest-cfgcmd.txt    compatibility versions of cmake did not have byproducts   option, cmake generating phony rules such files convince 'ninja'   build.    project authors should add missing byproducts or output options   custom commands produce these files. 

if oblige request of cmake error uncommenting build byproducts lines in external project command, cyclical dependency error. however, if leave build byproducts out of it, project seems build fine.

$ ninja ninja: error: dependency cycle: googletest-prefix/src/googletest-stamp/googletest-configure -> googletest-prefix/tmp/googletest-cfgcmd.txt -> googletest-prefix/src/googletest-stamp/googletest-configure 

i'm using cmake 3.4, ninja 1.6, , running on windows using msys2 package.

i added cmake_policy(set cmp0058 new) toplevel cmakelists.txt file --help-policy text explains to. no longer generates warnings afterwards. guess files aren't needed. not sure how they're getting picked dependencies.


Comments