summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorBenoit Neil <suky0001@free.fr>2009-04-06 22:45:17 +0000
committerBenoit Neil <suky0001@free.fr>2009-04-06 22:45:17 +0000
commit8cb8371011a8920f5b137ba6bec463d37262a393 (patch)
treea3bd54f440a12fdd14bb3fd6c5b819fdd015cadd /CMakeLists.txt
parent875c55d86bcfb35f01106865b60dcd1594bfc340 (diff)
downloadcurl-8cb8371011a8920f5b137ba6bec463d37262a393.tar.gz
Made the CMake scripts read Makefile.inc. Needs testing I guess.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt44
1 files changed, 44 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c87127be8..3113b3f52 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -770,6 +770,50 @@ FUNCTION(SETUP_CURL_DEPENDENCIES TARGET_NAME)
ENDIF()
ENDFUNCTION()
+# Ugly (but functional) way to include "Makefile.inc" by transforming it (= regenerate it).
+FUNCTION(TRANSFORM_MAKEFILE_INC INPUT_FILE OUTPUT_FILE)
+ FILE(READ ${INPUT_FILE} MAKEFILE_INC_TEXT)
+ STRING(REPLACE "$(top_srcdir)" "\${CURL_SOURCE_DIR}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
+ STRING(REGEX REPLACE "\\\\\n" "§!§" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
+ STRING(REGEX REPLACE "([a-zA-Z_][a-zA-Z0-9_]*)[\t ]*=[\t ]*([^\n]*\n)" "SET(\\1 \\2)\n" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
+ STRING(REPLACE "§!§" "\n" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
+ STRING(REGEX REPLACE "\\$\\(([a-zA-Z_][a-zA-Z0-9_]*)\\)" "\${\\1}" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
+ FILE(WRITE ${OUTPUT_FILE} ${MAKEFILE_INC_TEXT})
+
+ ### BUGGY METHOD 1
+ # FILE(STRINGS Makefile.inc MAKEFILE_INC_TEXT)
+ # STRING(REPLACE "# ./lib/Makefile.inc" "" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
+ # STRING(REPLACE " " " " MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) # Replace tabs with spaces
+
+ # #STRING(REGEX MATCH "CSOURCES *=" AAA ${MAKEFILE_INC_TEXT})
+ # #MESSAGE(STATUS ${AAA})
+
+ # STRING(REPLACE "CSOURCES =" "" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
+ # STRING(REPLACE "HHEADERS =" "" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
+
+ # STRING(REGEX REPLACE "[^ ]+\\.c" "" ${HEADERS_VAR} ${MAKEFILE_INC_TEXT}) # Remove source files and store into headers var
+ # STRING(REGEX REPLACE " +" " " ${HEADERS_VAR} ${${HEADERS_VAR}})
+ # STRING(REGEX REPLACE " " ";" ${HEADERS_VAR} ${${HEADERS_VAR}})
+
+ # STRING(REGEX REPLACE "[^ ]+\\.h" "" ${SOURCES_VAR} ${MAKEFILE_INC_TEXT}) # Remove headers and store into source files var
+ # STRING(REGEX REPLACE " +" " " ${SOURCES_VAR} ${${SOURCES_VAR}})
+ # STRING(REGEX REPLACE " " ";" ${SOURCES_VAR} ${${SOURCES_VAR}})
+
+ # SET(${HEADERS_VAR} ${${HEADERS_VAR}} PARENT_SCOPE)
+ # SET(${SOURCES_VAR} ${${SOURCES_VAR}} PARENT_SCOPE)
+
+ ### BUGGY METHOD 2
+ # FILE(READ Makefile.inc MAKEFILE_INC_TEXT)
+ # #STRING(REPLACE "\t" " " MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) # Replace tabs with spaces
+ # #STRING(REGEX REPLACE "\n+" "\n" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT}) # Remove empty lines (allow a simplification in the script)
+ # STRING(REGEX REPLACE "([A-Z]+)[\t ]*=[\t ]*" "SET(\\1 " MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
+ # #STRING(REGEX REPLACE "^(.*)[\t ]*[^\\]$" ")" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
+ # STRING(REGEX REPLACE "([^\\])\n" "\\1)\n" MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
+ # # STRING(REGEX REPLACE "CSOURCES *=" "SET(libCurl_SRCS " MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
+ # # STRING(REGEX REPLACE "HHEADERS *=" "SET(libCurl_HEADERS " MAKEFILE_INC_TEXT ${MAKEFILE_INC_TEXT})
+ # FILE(WRITE Makefile.inc.cmake ${MAKEFILE_INC_TEXT})
+ENDFUNCTION()
+
ADD_SUBDIRECTORY(lib)
IF(BUILD_CURL_EXE)
ADD_SUBDIRECTORY(src)