Mercurial > projects > qtd
comparison CMakeLists.txt @ 50:cc557203146c
CMake: fix building when path of source or build directory contain the reserve regex symbols.
author | SokoL_SD |
---|---|
date | Mon, 18 May 2009 13:09:46 +0000 |
parents | e00776053828 |
children | 2bd596a4b984 |
comparison
equal
deleted
inserted
replaced
49:e00776053828 | 50:cc557203146c |
---|---|
177 # quotes once here, i.e. with \" | 177 # quotes once here, i.e. with \" |
178 set(${pathname} \"${${pathname}}\") | 178 set(${pathname} \"${${pathname}}\") |
179 endif(${CMAKE_SYSTEM_NAME} STREQUAL Windows) | 179 endif(${CMAKE_SYSTEM_NAME} STREQUAL Windows) |
180 endmacro(MAKE_NATIVE_PATH) | 180 endmacro(MAKE_NATIVE_PATH) |
181 | 181 |
182 macro(regexseafestring outvariable) | |
183 set(${outvariable} ${ARGN}) | |
184 set(__regex_chars__ ^ $ . ] [ - * + ? | \( \)) | |
185 foreach(__regex_char__ ${__regex_chars__}) | |
186 string(REPLACE "${__regex_char__}" | |
187 "\\${__regex_char__}" ${outvariable} ${${outvariable}} | |
188 ) | |
189 endforeach(__regex_char__ ${__regex_chars__}) | |
190 endmacro(regexseafestring outvariable) | |
191 | |
182 ## Remove unnecessary travel to the object file. | 192 ## Remove unnecessary travel to the object file. |
183 ## path -- path to object file. | 193 ## path -- path to object file. |
184 ## Example: | 194 ## Example: |
185 ## set(path ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/target.dir/main.d.obj) | 195 ## set(path ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/target.dir/main.d.obj) |
186 ## obj_path(path) | 196 ## obj_path(path) |
187 ## message(STATUS ${path}) | 197 ## message(STATUS ${path}) |
188 ## Example output: | 198 ## Example output: |
189 ## -- CMakeFiles/target.dir/main.d.obj | 199 ## -- CMakeFiles/target.dir/main.d.obj |
190 macro(OBJ_PATH path) | 200 macro(OBJ_PATH path) |
191 set(test) | 201 regexseafestring(__cbd_safe__ ${CMAKE_CURRENT_BINARY_DIR}) |
192 string(REGEX MATCH "${CMAKE_CURRENT_BINARY_DIR}/.*" test "${${path}}") | 202 regexseafestring(__csd_safe__ ${CMAKE_CURRENT_SOURCE_DIR}) |
193 if(NOT ${test} EQUAL "") | 203 set(regexp_str "(${__cbd_safe__}/|${__csd_safe__}/|)(.+)") |
194 string(LENGTH "${CMAKE_CURRENT_BINARY_DIR}" first) | 204 string(REGEX REPLACE ${regexp_str} "\\2" ${path} "${${path}}") |
195 string(LENGTH "${${path}}" last) | |
196 math(EXPR first "${first} + 1") | |
197 math(EXPR len "${last} - ${first}") | |
198 string(SUBSTRING "${${path}}" ${first} ${len} ${path}) | |
199 else(NOT ${test} EQUAL "") | |
200 string(REGEX MATCH "${CMAKE_CURRENT_SOURCE_DIR}/.*" test "${${path}}") | |
201 if(NOT ${test} EQUAL "") | |
202 string(LENGTH "${CMAKE_CURRENT_SOURCE_DIR}" first) | |
203 string(LENGTH "${${path}}" last) | |
204 math(EXPR first "${first} + 1") | |
205 math(EXPR len "${last} - ${first}") | |
206 string(SUBSTRING "${${path}}" ${first} ${len} ${path}) | |
207 endif(NOT ${test} EQUAL "") | |
208 endif(NOT ${test} EQUAL "") | |
209 endmacro(OBJ_PATH) | 205 endmacro(OBJ_PATH) |
210 | 206 |
211 | 207 |
212 ## Compile d files. | 208 ## Compile d files. |
213 ## target -- name of a new target. | 209 ## target -- name of a new target. |
530 set(${package}_lib_param ${${package}_lib_param} ${link}) | 526 set(${package}_lib_param ${${package}_lib_param} ${link}) |
531 endforeach(link ${link_example}) | 527 endforeach(link ${link_example}) |
532 endif(${CMAKE_SYSTEM_NAME} STREQUAL Windows AND D_IS_MARS) | 528 endif(${CMAKE_SYSTEM_NAME} STREQUAL Windows AND D_IS_MARS) |
533 | 529 |
534 if(GENERATE_DI_FILES) | 530 if(GENERATE_DI_FILES) |
535 set(regexp_str "(${CMAKE_SOURCE_DIR}/qt/d${D_VERSION}|${CMAKE_BINARY_DIR}|${CMAKE_SOURCE_DIR})/([A-Za-z0-9\\-_\\\\/]+)[/]+([A-Za-z0-9\\-_\\\\]+).d") | 531 regexseafestring(cbd_safe ${CMAKE_BINARY_DIR}) |
532 regexseafestring(csd_safe ${CMAKE_SOURCE_DIR}) | |
533 set(regexp_str "(${csd}/qt/d${D_VERSION}|${csd_safe}|${cbd_safe})/([A-Za-z0-9\\-_\\\\/]+)[/]+([A-Za-z0-9\\-_\\\\]+).d") | |
536 foreach(source ${d_sources}) | 534 foreach(source ${d_sources}) |
537 # find_file(source ${source} PATHS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} | 535 # find_file(source ${source} PATHS ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} |
538 # ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}) | 536 # ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}) |
539 string(REGEX REPLACE ${regexp_str} "\\2" inc_path "${source}") | 537 string(REGEX REPLACE ${regexp_str} "\\2" inc_path "${source}") |
540 string(REGEX REPLACE ${regexp_str} "\\3" file_name "${source}") | 538 string(REGEX REPLACE ${regexp_str} "\\3" file_name "${source}") |