Merge pull request #194 from rolk/194_bugfix

Test strings on length before content
This commit is contained in:
Bård Skaflestad 2013-03-13 03:30:20 -07:00
commit ee748e6e64

View File

@ -29,9 +29,19 @@ endif (CMAKE_GENERATOR MATCHES "Unix Makefiles")
# source dir and most likely doesn't contain other projects) anyway,
# i.e. we only copy if we are truly out-of-source
string (LENGTH "${PROJECT_SOURCE_DIR}/" _src_dir_len)
string (SUBSTRING "${PROJECT_BINARY_DIR}/" 0 ${_src_dir_len} _proj_prefix)
if (NOT "${PROJECT_SOURCE_DIR}/" STREQUAL "${_proj_prefix}")
string (LENGTH "${PROJECT_BINARY_DIR}/" _bin_dir_len)
if (_src_dir_len GREATER _bin_dir_len)
set (_not_substring TRUE)
else (_src_dir_len GREATER _bin_dir_len)
string (SUBSTRING "${PROJECT_BINARY_DIR}/" 0 ${_src_dir_len} _proj_prefix)
if ("${PROJECT_SOURCE_DIR}/" STREQUAL "${_proj_prefix}")
set (_not_substring FALSE)
else ("${PROJECT_SOURCE_DIR}/" STREQUAL "${_proj_prefix}")
set (_not_substring TRUE)
endif ("${PROJECT_SOURCE_DIR}/" STREQUAL "${_proj_prefix}")
endif (_src_dir_len GREATER _bin_dir_len)
if (_not_substring)
execute_process (COMMAND
${CMAKE_COMMAND} -E copy_if_different ${PROJECT_SOURCE_DIR}/dune.module ${PROJECT_BINARY_DIR}/dune.module
)
endif (NOT "${PROJECT_SOURCE_DIR}/" STREQUAL "${_proj_prefix}")
endif (_not_substring)