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.
This commit is contained in:
Shawn Waldon 2017-08-17 12:02:50 -04:00
parent b9e69217ae
commit 1672093787
2 changed files with 28 additions and 10 deletions

@ -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 # Send the libraries created for test builds to their own directory so as to
# not polute the directory with useful libraries. # not polute the directory with useful libraries.
set_target_properties(TestBuild_${name} PROPERTIES set_target_properties(TestBuild_${name} PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}/testbuilds ARCHIVE_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH}/testbuilds
LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}/testbuilds LIBRARY_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH}/testbuilds
RUNTIME_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}/testbuilds RUNTIME_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH}/testbuilds
) )
endfunction(vtkm_add_header_build_test) endfunction(vtkm_add_header_build_test)
@ -287,6 +287,12 @@ function(vtkm_unit_tests)
add_executable(${test_prog} ${TestSources}) add_executable(${test_prog} ${TestSources})
endif (VTKm_UT_CUDA) 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 #do it as a property value so we don't pollute the include_directories
#for any other targets #for any other targets
target_include_directories(${test_prog} PRIVATE ${VTKm_INCLUDE_DIRS}) target_include_directories(${test_prog} PRIVATE ${VTKm_INCLUDE_DIRS})
@ -420,6 +426,12 @@ function(vtkm_worklet_unit_tests device_adapter)
else() else()
add_executable(${test_prog} ${unit_test_drivers} ${unit_test_srcs}) add_executable(${test_prog} ${unit_test_drivers} ${unit_test_srcs})
endif() 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_include_directories(${test_prog} PRIVATE ${VTKm_INCLUDE_DIRS})
target_link_libraries(${test_prog} PRIVATE vtkm_cont ${VTKm_LIBRARIES}) 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}) add_executable(${benchmark_prog} ${file} ${benchmark_headers})
endif() 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} set_source_files_properties(${benchmark_headers}
PROPERTIES HEADER_FILE_ONLY TRUE) 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. # Make sure libraries go to lib directory and dll go to bin directory.
# Mostly important on Windows. # Mostly important on Windows.
set_target_properties(${lib_name} PROPERTIES set_target_properties(${lib_name} PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH} ARCHIVE_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH}
LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH} LIBRARY_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH}
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} RUNTIME_OUTPUT_DIRECTORY ${VTKm_EXECUTABLE_OUTPUT_PATH}
) )
if(MSVC) if(MSVC)

@ -144,21 +144,21 @@ endif (VTKm_ENABLE_CUDA)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
## Set the directory where the binaries will be stored ## Set the directory where the binaries will be stored
set( EXECUTABLE_OUTPUT_PATH set( VTKm_EXECUTABLE_OUTPUT_PATH
${PROJECT_BINARY_DIR}/bin ${PROJECT_BINARY_DIR}/bin
CACHE PATH CACHE PATH
"Directory where all executable will be stored" "Directory where all executable will be stored"
) )
## Set the directory where the libraries 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 ${PROJECT_BINARY_DIR}/lib
CACHE PATH CACHE PATH
"Directory where all the libraries will be stored" "Directory where all the libraries will be stored"
) )
mark_as_advanced( mark_as_advanced(
EXECUTABLE_OUTPUT_PATH VTKm_EXECUTABLE_OUTPUT_PATH
LIBRARY_OUTPUT_PATH) VTKm_LIBRARY_OUTPUT_PATH)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Add "meta" tests that check the state of the repository # Add "meta" tests that check the state of the repository