[Cmake] please provide example of use of STRING(REGEX REPLACE ... )
Bitter, Ingmar (NIH/CC/DRD)
IBitter at cc.nih.gov
Tue Apr 1 14:10:04 EST 2003
Hi Andy,
Thanks for the current dir info.
In my MS VC++ 6.0 the current file name in the title bar appears as
C:\...\foo.cpp
This is wonderful when you develop on 320x200 pixel resolution, but in
today's environments you usually have lots of empty space in the title bar.
As I do not know how to change the title bar, I would still like to know
where my project is located (especially when switching back and forth
between the cvs main trunk version of a project and one with local changes).
Putting the path into the workspace name gives me this information.
-Ingmar
-----Original Message-----
...
> PS: the directory names created by CMake have forward slashes, hence the
> following sets the project name (or workspace name in VC++60 terms) the
> complete path which I find very helpful
>
> ###projectDir/build/CMakeLists.txt // build in separate dir from sources
>
> # find current dir
> FIND_PATH(BUILD_PATH CMakeLists.txt . )
This is CMAKE_CURRENT_SOURCE_DIR. There is also
CMAKE_CURRENT_BINARY_DIR.
> # remove ":" from path
> STRING(REGEX REPLACE ":" "_" PROJECT_NAME ${BUILD_PATH})
#
> # convert "/" to "_"
> STRING(REGEX REPLACE "/" "_" PROJECT_NAME ${PROJECT_NAME})
>
> # remove build subdir from path
> STRING(REGEX REPLACE "_build" "" PROJECT_NAME ${PROJECT_NAME})
>
> # store new assembled name as project name
> PROJECT(${PROJECT_NAME})
What is wrong with cmake variable PROJECT_NAME?
Why would you want to store project name to be path to source?
Andy
More information about the CMake
mailing list