From 1672093787d413739348f3a5f0e66e8abf724336 Mon Sep 17 00:00:00 2001 From: Shawn Waldon Date: Thu, 17 Aug 2017 12:02:50 -0400 Subject: [PATCH] Avoid redefining CMake default variables When used as a submodule, redefining LIBRARY_OUTPUT_PATH and EXECUTABLE_OUTPUT_PATH fails since the CMake default variables from the containing project already exist. --- CMake/VTKmMacros.cmake | 30 ++++++++++++++++++++++++------ CMakeLists.txt | 8 ++++---- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/CMake/VTKmMacros.cmake b/CMake/VTKmMacros.cmake index 1056cb7ac..e1ae3310b 100755 --- a/CMake/VTKmMacros.cmake +++ b/CMake/VTKmMacros.cmake @@ -135,9 +135,9 @@ function(vtkm_add_header_build_test name dir_prefix use_cuda) # Send the libraries created for test builds to their own directory so as to # not polute the directory with useful libraries. set_target_properties(TestBuild_${name} PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}/testbuilds - LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}/testbuilds - RUNTIME_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}/testbuilds + ARCHIVE_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH}/testbuilds + LIBRARY_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH}/testbuilds + RUNTIME_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH}/testbuilds ) endfunction(vtkm_add_header_build_test) @@ -287,6 +287,12 @@ function(vtkm_unit_tests) add_executable(${test_prog} ${TestSources}) endif (VTKm_UT_CUDA) + set_target_properties(${test_prog} PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH} + LIBRARY_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH} + RUNTIME_OUTPUT_DIRECTORY ${VTKm_EXECUTABLE_OUTPUT_PATH} + ) + #do it as a property value so we don't pollute the include_directories #for any other targets target_include_directories(${test_prog} PRIVATE ${VTKm_INCLUDE_DIRS}) @@ -420,6 +426,12 @@ function(vtkm_worklet_unit_tests device_adapter) else() add_executable(${test_prog} ${unit_test_drivers} ${unit_test_srcs}) endif() + + set_target_properties(${test_prog} PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH} + LIBRARY_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH} + RUNTIME_OUTPUT_DIRECTORY ${VTKm_EXECUTABLE_OUTPUT_PATH} + ) target_include_directories(${test_prog} PRIVATE ${VTKm_INCLUDE_DIRS}) target_link_libraries(${test_prog} PRIVATE vtkm_cont ${VTKm_LIBRARIES}) @@ -549,6 +561,12 @@ function(vtkm_benchmarks device_adapter) add_executable(${benchmark_prog} ${file} ${benchmark_headers}) endif() + set_target_properties(${benchmark_prog} PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH} + LIBRARY_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH} + RUNTIME_OUTPUT_DIRECTORY ${VTKm_EXECUTABLE_OUTPUT_PATH} + ) + set_source_files_properties(${benchmark_headers} PROPERTIES HEADER_FILE_ONLY TRUE) @@ -686,9 +704,9 @@ function(vtkm_library) # Make sure libraries go to lib directory and dll go to bin directory. # Mostly important on Windows. set_target_properties(${lib_name} PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH} - LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH} - RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} + ARCHIVE_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH} + LIBRARY_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH} + RUNTIME_OUTPUT_DIRECTORY ${VTKm_EXECUTABLE_OUTPUT_PATH} ) if(MSVC) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5fe2f7f7e..269cb4ef7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,21 +144,21 @@ endif (VTKm_ENABLE_CUDA) #----------------------------------------------------------------------------- ## Set the directory where the binaries will be stored -set( EXECUTABLE_OUTPUT_PATH +set( VTKm_EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE PATH "Directory where all executable will be stored" ) ## Set the directory where the libraries will be stored -set( LIBRARY_OUTPUT_PATH +set( VTKm_LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib CACHE PATH "Directory where all the libraries will be stored" ) mark_as_advanced( - EXECUTABLE_OUTPUT_PATH - LIBRARY_OUTPUT_PATH) + VTKm_EXECUTABLE_OUTPUT_PATH + VTKm_LIBRARY_OUTPUT_PATH) #----------------------------------------------------------------------------- # Add "meta" tests that check the state of the repository