47 lines
1.5 KiB
CMake
47 lines
1.5 KiB
CMake
|
PROJECT(StringFileTest)
|
||
|
INCLUDE_DIRECTORIES(${StringFileTest_BINARY_DIR})
|
||
|
|
||
|
FILE(READ "${CMAKE_CURRENT_SOURCE_DIR}/InputFile.h.in" infile)
|
||
|
STRING(REGEX MATCH "[cC][mM][aA][kK][eE]" rmvar "CMake is great")
|
||
|
STRING(REGEX MATCHALL "[cC][mM][aA][kK][eE]" rmallvar "CMake is better than cmake or CMake")
|
||
|
STRING(REGEX REPLACE "[Aa][uU][tT][oO]([cC][oO][nN][fF]|[mM][aA][kK][eE])"
|
||
|
"CMake" rrepvar "People should use Autoconf and Automake")
|
||
|
STRING(COMPARE EQUAL "CMake" "Autoconf" nceqvar)
|
||
|
STRING(COMPARE EQUAL "CMake" "CMake" ceqvar)
|
||
|
STRING(COMPARE NOTEQUAL "CMake" "Autoconf" cneqvar)
|
||
|
STRING(COMPARE NOTEQUAL "CMake" "CMake" ncneqvar)
|
||
|
STRING(COMPARE LESS "before" "after" nclvar)
|
||
|
STRING(COMPARE LESS "max" "min" clvar)
|
||
|
STRING(COMPARE GREATER "before" "after" cgvar)
|
||
|
STRING(COMPARE GREATER "max" "min" ncgvar)
|
||
|
STRING(ASCII 67 109 97 107 101 savar)
|
||
|
STRING(TOUPPER "CMake" tuvar)
|
||
|
STRING(TOLOWER "CMake" tlvar)
|
||
|
|
||
|
FILE(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Includes")
|
||
|
|
||
|
SET(file "${CMAKE_CURRENT_BINARY_DIR}/Includes/Values.h")
|
||
|
FILE(WRITE "${file}" "/* this file is generated */\n")
|
||
|
FOREACH(var
|
||
|
rmvar
|
||
|
rmallvar
|
||
|
rrepvar
|
||
|
nceqvar
|
||
|
ceqvar
|
||
|
cneqvar
|
||
|
ncneqvar
|
||
|
nclvar
|
||
|
clvar
|
||
|
cgvar
|
||
|
ncgvar
|
||
|
savar
|
||
|
tuvar
|
||
|
tlvar)
|
||
|
FILE(APPEND "${file}" "#define ${var} \"${${var}}\"")
|
||
|
ENDFOREACH(var)
|
||
|
|
||
|
STRING(REGEX REPLACE "includefile" "${file}" outfile "${infile}")
|
||
|
FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/OutputFile.h" "${outfile}")
|
||
|
|
||
|
ADD_EXECUTABLE(StringFileTest StringFile.cxx)
|