From 5277134efa63a33ead0ddbb1ae55badb19909573 Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Mon, 13 Feb 2017 23:24:38 -0800 Subject: [PATCH 1/5] Removed empty install() command --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e9b44d5..96e892b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -116,7 +116,6 @@ else(BUILD_STATIC_LIBS) add_dependencies(xmltest ${TARGET_DATA_COPY}) target_link_libraries(xmltest tinyxml2_static) endif() -install(TARGETS DESTINATION ${CMAKE_INSTALL_BINDIR}) install(FILES tinyxml2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) From 969b8c22343a19c0474395a0af701c8513413ed0 Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Mon, 13 Feb 2017 23:40:16 -0800 Subject: [PATCH 2/5] Replaced DATA_COPY target with post build command to copy the resources directory --- CMakeLists.txt | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 96e892b..0a21405 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,25 +29,6 @@ set(GENERIC_LIB_SOVERSION "4") include_directories("${CMAKE_CURRENT_SOURCE_DIR}/.") -################################ -# Add custom target to copy all data - -set(TARGET_DATA_COPY DATA_COPY) -set(DATA_COPY_FILES) -if(NOT ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR}) - foreach(data dream.xml empty.xml utf8test.xml utf8testverify.xml) - set(DATA_COPY_SRC ${CMAKE_CURRENT_SOURCE_DIR}/resources/${data}) - set(DATA_COPY_DEST ${CMAKE_CURRENT_BINARY_DIR}/resources/${data}) - add_custom_command( - OUTPUT ${DATA_COPY_DEST} - COMMAND ${CMAKE_COMMAND} - ARGS -E copy ${DATA_COPY_SRC} ${DATA_COPY_DEST} - DEPENDS ${DATA_COPY_SRC}) - list(APPEND DATA_COPY_FILES ${DATA_COPY_DEST}) - endforeach(data) -endif(NOT ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR}) -add_custom_target(${TARGET_DATA_COPY} DEPENDS ${DATA_COPY_FILES}) - ################################ # Add definitions @@ -109,14 +90,17 @@ endif() add_executable(xmltest xmltest.cpp) if(BUILD_SHARED_LIBS) add_dependencies(xmltest tinyxml2) - add_dependencies(xmltest ${TARGET_DATA_COPY}) target_link_libraries(xmltest tinyxml2) else(BUILD_STATIC_LIBS) add_dependencies(xmltest tinyxml2_static) - add_dependencies(xmltest ${TARGET_DATA_COPY}) target_link_libraries(xmltest tinyxml2_static) endif() +# Copy test resources +add_custom_command(TARGET xmltest POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/resources ${CMAKE_BINARY_DIR}/resources +) + install(FILES tinyxml2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) foreach(p LIB INCLUDE) From 6bf64fb149dae91946971ed39278bb315b975bef Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Tue, 21 Feb 2017 12:00:38 -0800 Subject: [PATCH 3/5] Use CMake to create resources/out directory --- CMakeLists.txt | 4 +++- xmltest.cpp | 17 ----------------- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a21405..9a4c0cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,9 +96,11 @@ else(BUILD_STATIC_LIBS) target_link_libraries(xmltest tinyxml2_static) endif() -# Copy test resources +# Copy test resources and create test output directory add_custom_command(TARGET xmltest POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/resources ${CMAKE_BINARY_DIR}/resources + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/resources/out + COMMENT "Configuring xmltest resources directory: ${CMAKE_BINARY_DIR}/resources" ) install(FILES tinyxml2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/xmltest.cpp b/xmltest.cpp index b6bb76f..8221e68 100644 --- a/xmltest.cpp +++ b/xmltest.cpp @@ -10,16 +10,10 @@ #include #if defined( _MSC_VER ) - #include // _mkdir #include #define WIN32_LEAN_AND_MEAN #include _CrtMemState startMemState; - _CrtMemState endMemState; -#elif defined(MINGW32) || defined(__MINGW32__) - #include // mkdir -#else - #include // mkdir #endif using namespace tinyxml2; @@ -299,17 +293,6 @@ int main( int argc, const char ** argv ) _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF); #endif - #if defined(_MSC_VER) || defined(MINGW32) || defined(__MINGW32__) - #if defined __MINGW64_VERSION_MAJOR && defined __MINGW64_VERSION_MINOR - //MINGW64: both 32 and 64-bit - mkdir( "resources/out/" ); - #else - _mkdir( "resources/out/" ); - #endif - #else - mkdir( "resources/out/", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); - #endif - { TIXMLASSERT( true ); } From 7f2ce0dc0e1968a1d5e9ffcc905ea85e3015c66f Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Tue, 21 Feb 2017 12:27:59 -0800 Subject: [PATCH 4/5] Updated Windows build script to change directory instead of copying files to run xmltest --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index aac8867..0c60b67 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,5 +3,5 @@ before_build: build_script: - msbuild tinyxml2.sln /m /p:Configuration=Release /t:ALL_BUILD - - copy Release\xmltest.exe .\ && copy Release\tinyxml2.dll .\ + - cd Release - xmltest.exe From 1e0b4e6b8aceaabb676adb8d1bc531bb2ff3129f Mon Sep 17 00:00:00 2001 From: Jimmy Nguyen Date: Tue, 21 Feb 2017 12:31:23 -0800 Subject: [PATCH 5/5] Use generator expression to specify target output directory for resources directory --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a4c0cc..dd09fe5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,8 +98,8 @@ endif() # Copy test resources and create test output directory add_custom_command(TARGET xmltest POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/resources ${CMAKE_BINARY_DIR}/resources - COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/resources/out + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/resources $/resources + COMMAND ${CMAKE_COMMAND} -E make_directory $/resources/out COMMENT "Configuring xmltest resources directory: ${CMAKE_BINARY_DIR}/resources" )