# HG changeset patch # User David Demelier # Date 1522345160 -7200 # Node ID 65a54b126c08cde76f8598dbcb00578b4c13e1be # Parent e9153b85b9bdfb519096f97bc692b1befe25a760 CMake: do not use TESTS_BINARY_DIR in libirccd-test The variable is not defined on initial CMake because the add_subdirectory(tests) appears after libirccd-test creation. Use a dedicated CMAKE_BINARY_DIR/tmp directory to store temporary files needed for CLI tests. diff -r e9153b85b9bd -r 65a54b126c08 cmake/function/IrccdDefineLibrary.cmake --- a/cmake/function/IrccdDefineLibrary.cmake Thu Mar 29 09:13:51 2018 +0200 +++ b/cmake/function/IrccdDefineLibrary.cmake Thu Mar 29 19:39:20 2018 +0200 @@ -54,7 +54,14 @@ add_library(${LIB_TARGET} ${type} ${LIB_SOURCES}) target_include_directories(${LIB_TARGET} PRIVATE ${LIB_LOCAL_INCLUDES} PUBLIC ${LIB_PUBLIC_INCLUDES}) - target_compile_definitions(${LIB_TARGET} PUBLIC ${LIB_FLAGS}) + target_compile_definitions( + ${LIB_TARGET} + PRIVATE + CMAKE_BINARY_DIR="${CMAKE_BINARY_DIR}" + CMAKE_SOURCE_DIR="${CMAKE_SOURCE_DIR}" + PUBLIC + ${LIB_FLAGS} + ) target_link_libraries(${LIB_TARGET} ${LIB_LIBRARIES}) set_target_properties( ${LIB_TARGET} diff -r e9153b85b9bd -r 65a54b126c08 libcommon/irccd/config.hpp --- a/libcommon/irccd/config.hpp Thu Mar 29 09:13:51 2018 +0200 +++ b/libcommon/irccd/config.hpp Thu Mar 29 19:39:20 2018 +0200 @@ -53,6 +53,7 @@ */ inline config(std::string path = "") : document(path.empty() ? ini::document() : ini::read_file(path)) + , path_(std::move(path)) { } diff -r e9153b85b9bd -r 65a54b126c08 libirccd-test/CMakeLists.txt --- a/libirccd-test/CMakeLists.txt Thu Mar 29 09:13:51 2018 +0200 +++ b/libirccd-test/CMakeLists.txt Thu Mar 29 19:39:20 2018 +0200 @@ -40,5 +40,4 @@ FLAGS IRCCD_EXECUTABLE="$" IRCCDCTL_EXECUTABLE="$" - TESTS_BINARY_DIR="${tests_BINARY_DIR}" ) diff -r e9153b85b9bd -r 65a54b126c08 libirccd-test/irccd/test/cli_test.cpp --- a/libirccd-test/irccd/test/cli_test.cpp Thu Mar 29 09:13:51 2018 +0200 +++ b/libirccd-test/irccd/test/cli_test.cpp Thu Mar 29 19:39:20 2018 +0200 @@ -36,7 +36,8 @@ { std::ostringstream oss; - oss << IRCCD_EXECUTABLE << " -fc " << TESTS_BINARY_DIR << "/" << config; + oss << IRCCD_EXECUTABLE << " -fc "; + oss << CMAKE_BINARY_DIR "/tmp/" << config; irccd_ = proc::child(oss.str()); @@ -50,8 +51,9 @@ std::future out; std::future err; - oss << IRCCDCTL_EXECUTABLE << " -c " << TESTS_BINARY_DIR << "/irccdctl.conf " - << string_util::join(args, " "); + oss << IRCCDCTL_EXECUTABLE << " -c "; + oss << CMAKE_BINARY_DIR << "/tmp/irccdctl.conf "; + oss << string_util::join(args, " "); boost::asio::io_service io; proc::child irccdctl( diff -r e9153b85b9bd -r 65a54b126c08 tests/CMakeLists.txt --- a/tests/CMakeLists.txt Thu Mar 29 09:13:51 2018 +0200 +++ b/tests/CMakeLists.txt Thu Mar 29 19:39:20 2018 +0200 @@ -29,7 +29,7 @@ foreach (c ${CONFIGS}) configure_file( ${tests_SOURCE_DIR}/data/${c} - ${tests_BINARY_DIR}/${c} + ${CMAKE_BINARY_DIR}/tmp/${c} @ONLY ) endforeach () diff -r e9153b85b9bd -r 65a54b126c08 tests/data/irccd-plugins.conf --- a/tests/data/irccd-plugins.conf Thu Mar 29 09:13:51 2018 +0200 +++ b/tests/data/irccd-plugins.conf Thu Mar 29 19:39:20 2018 +0200 @@ -1,6 +1,6 @@ [transport] type = "unix" -path = "@tests_BINARY_DIR@/irccd.sock" +path = "@CMAKE_BINARY_DIR@/tmp/irccd.sock" [plugins] foo = "@tests_SOURCE_DIR@/data/foo.js" diff -r e9153b85b9bd -r 65a54b126c08 tests/data/irccdctl.conf --- a/tests/data/irccdctl.conf Thu Mar 29 09:13:51 2018 +0200 +++ b/tests/data/irccdctl.conf Thu Mar 29 19:39:20 2018 +0200 @@ -1,3 +1,3 @@ [connect] type = "unix" -path = "@tests_BINARY_DIR@/irccd.sock" +path = "@CMAKE_BINARY_DIR@/tmp/irccd.sock"