No, it's the other way around. e.g. CMAKE_CURRENT_SOURCE_DIR = "E:/LBM_subversion/source/topology/amr3d/lbmd3q19/singlephase/testcases/RCF/ all_in_one"
And I'm looking for Path="E:/LBM_subversion/source/" And the keyword I'm looking for is: "/source/" That's the only keyword that's possible... The path to source can be different and also the path to the CMakeLists.txt (depend on the project and the machine I'm on). So later one I'll check if the folder "roost/basics" exists... then the "source" folder is correct. Else wise I have to set the path manually. SirAnn -----Ursprüngliche Nachricht----- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von Brandon Van Every Gesendet: Montag, 3. Dezember 2007 21:01 An: cmake@cmake.org Betreff: Re: [CMake] SUBSTRING - STRING - shorten a string variable On Dec 3, 2007 12:56 PM, Sören Freudiger <[EMAIL PROTECTED]> wrote: > > > > > Hello > > Following problem: > > > > My CMakeList.txt file is somewhere like: > > E:/LBM_subversion/source/topology/amr3d/lbmd3q19/singlephase/testcases/RCF/a ll_in_one > > > > Now I want to have only the substring: > > E:/LBM_subversion/source > > > > Is it possible to get last string with the help of CMAKE_CURRENT_SOURCE_DIR? > I just want to know the position of "source". Thus I can shorten the string > stored in CMAKE_CURRENT_SOURCE_DIR very easy. I do not always know the path > behind source/ If you know the string contains "${CMAKE_CURRENT_SOURCE_DIR}" then you can do: string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}" "" relative_path "${absolute_path}") If you need to find out whether the string contains "${CMAKE_CURRENT_SOURCE_DIR}" then the following will work as long as "${CMAKE_CURRENT_SOURCE_DIR}" doesn't contain regex special characters. if(absolute_path MATCHES "^${CMAKE_CURRENT_SOURCE_DIR}") # blah blah blah If "${CMAKE_CURRENT_SOURCE_DIR}" contains regex special characters, you'll have to double escape them. string(REPLACE "\\" "\\\\" escaped_path "${toplevel_path}") string(REGEX REPLACE "([][.?*+|()$^-])" "\\\\\\1" escaped_path "${escaped_path}") if(absolute_path MATCHES "^${escaped_path}") string(REPLACE "${toplevel_path}" "" relative_path "${absolute_path}") Cheers, Brandon Van Every _______________________________________________ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake _______________________________________________ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake