null+****@clear*****
null+****@clear*****
2012年 4月 12日 (木) 19:03:25 JST
Kouhei Sutou 2012-04-12 19:03:25 +0900 (Thu, 12 Apr 2012) New Revision: 6d8d0818c8e3c8ede0334c3d690f060b3744c8cc Log: cmake: extract read_file_list Copied files: build/cmake_modules/ReadFileList.cmake (from lib/CMakeLists.txt) Modified files: lib/CMakeLists.txt Copied: build/cmake_modules/ReadFileList.cmake (+12 -16) 50% =================================================================== --- lib/CMakeLists.txt 2012-04-12 18:52:18 +0900 (e4e1fc9) +++ build/cmake_modules/ReadFileList.cmake 2012-04-12 19:03:25 +0900 (0185879) @@ -13,19 +13,15 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR}/dat - ) - -file(READ ${CMAKE_CURRENT_SOURCE_DIR}/sources.am LIBGROONGA_SOURCES) -# Remove variable declaration at the first line: -# "libgroonga_la_SOURCES = \" -> "" -string(REGEX REPLACE "^.*=[ \t]*\\\\" "" - LIBGROONGA_SOURCES "${LIBGROONGA_SOURCES}") -# Remove white spaces: " com.c \\\n com.h \\\n" -> "com.c\\com.h" -string(REGEX REPLACE "[ \t\n]" "" LIBGROONGA_SOURCES "${LIBGROONGA_SOURCES}") -# Convert string to list: "com.c\\com.h" -> "com.c;com.h" -# NOTE: List in CMake is ";" separated string. -string(REGEX REPLACE "\\\\" ";" LIBGROONGA_SOURCES "${LIBGROONGA_SOURCES}") - -add_library(groonga SHARED ${LIBGROONGA_SOURCES}) +macro(read_file_list file_name output_variable) + file(READ ${file_name} ${output_variable}) + # Remove variable declaration at the first line: + # "libgroonga_la_SOURCES = \" -> "" + string(REGEX REPLACE "^.*=[ \t]*\\\\" "" + ${output_variable} "${${output_variable}}") + # Remove white spaces: " com.c \\\n com.h \\\n" -> "com.c\\com.h" + string(REGEX REPLACE "[ \t\n]" "" ${output_variable} "${${output_variable}}") + # Convert string to list: "com.c\\com.h" -> "com.c;com.h" + # NOTE: List in CMake is ";" separated string. + string(REGEX REPLACE "\\\\" ";" ${output_variable} "${${output_variable}}") +endmacro() Modified: lib/CMakeLists.txt (+3 -10) =================================================================== --- lib/CMakeLists.txt 2012-04-12 18:52:18 +0900 (e4e1fc9) +++ lib/CMakeLists.txt 2012-04-12 19:03:25 +0900 (aa68161) @@ -17,15 +17,8 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/dat ) -file(READ ${CMAKE_CURRENT_SOURCE_DIR}/sources.am LIBGROONGA_SOURCES) -# Remove variable declaration at the first line: -# "libgroonga_la_SOURCES = \" -> "" -string(REGEX REPLACE "^.*=[ \t]*\\\\" "" - LIBGROONGA_SOURCES "${LIBGROONGA_SOURCES}") -# Remove white spaces: " com.c \\\n com.h \\\n" -> "com.c\\com.h" -string(REGEX REPLACE "[ \t\n]" "" LIBGROONGA_SOURCES "${LIBGROONGA_SOURCES}") -# Convert string to list: "com.c\\com.h" -> "com.c;com.h" -# NOTE: List in CMake is ";" separated string. -string(REGEX REPLACE "\\\\" ";" LIBGROONGA_SOURCES "${LIBGROONGA_SOURCES}") +include(${CMAKE_SOURCE_DIR}/build/cmake_modules/ReadFileList.cmake) + +read_file_list(${CMAKE_CURRENT_SOURCE_DIR}/sources.am LIBGROONGA_SOURCES) add_library(groonga SHARED ${LIBGROONGA_SOURCES})