summaryrefslogtreecommitdiff
path: root/lang
diff options
context:
space:
mode:
authorcyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864>2008-12-17 20:18:40 +0000
committercyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864>2008-12-17 20:18:40 +0000
commit81b7aa657110db03ceb861d8206fc6e805ede9c8 (patch)
tree8437f5ce65de3e27e5e02196711bd770aa86b7f5 /lang
parentfd45a3ad4219bffcf2f68fcc1dce3ff33b531b89 (diff)
Massive cleanup of the CMakeLists.txt files to finalize them.
Edited configuration scripts for *nix and Windows to use CMake as well as support both in-source and out-of-source builds. Changed directory structure for *nix to match Windows to remove some conditionals in both CMake and Anope itself. git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1841 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'lang')
-rw-r--r--lang/CMakeLists.txt102
1 files changed, 41 insertions, 61 deletions
diff --git a/lang/CMakeLists.txt b/lang/CMakeLists.txt
index 874c9f763..05e7becce 100644
--- a/lang/CMakeLists.txt
+++ b/lang/CMakeLists.txt
@@ -1,103 +1,83 @@
-#if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
-# set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR})
-#else(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
-# file(RELATIVE_PATH DIR ${Anope_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
-# set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/${DIR})
-#endif(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
-
-#add_custom_command(OUTPUT ${BUILD_DIR}/langcomp
-# COMMAND ${MY_COMPILER} ${MY_COMP_ARG} ${CMAKE_CXX_CFLAGS} langcomp.c -o ${BUILD_DIR}/langcomp
-# MAIN_DEPENDENCY langcomp.c
-#)
-#add_custom_target(lang_langcomp DEPENDS ${BUILD_DIR}/langcomp)
+# Set the source file for langcomp to use C++ as well as set it's compile flags
set_source_files_properties(langcomp.c PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
-#add_executable(${BUILD_DIR}/langcomp langcomp.c)
+# Generate langcomp and set it's linker flags
add_executable(langcomp langcomp.c)
set_target_properties(langcomp PROPERTIES LINK_FLAGS "${LDFLAGS}")
-#set_target_properties(langcomp PROPERTIES COMPILE_FLAGS ${CXXFLAGS})
-#set_target_properties(${BUILD_DIR}/langcomp PROPERTIES LINKER_LANGUAGE CXX)
-#add_custom_command(OUTPUT ${BUILD_DIR}/index
-# COMMAND ${GREP} '^[A-Z]' en_us.l > ${BUILD_DIR}/index
-# MAIN_DEPENDENCY en_us.l
-#)
-if(WIN32)
+# If grep or perl don't exist on the system, build langtool to generate index and language.h
+if(NOT GREP OR NOT PERL)
+ # Set the source file for langtool to use C++ as well as set it's compile flags
set_source_files_properties(langtool.c PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}")
+ # Generate langtool and set it's linker flags
add_executable(langtool langtool.c)
set_target_properties(langtool PROPERTIES LINK_FLAGS "${LDFLAGS}")
- add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/index
- COMMAND langtool index ${CMAKE_CURRENT_SOURCE_DIR}/en_us.l ${CMAKE_CURRENT_BINARY_DIR}/index
- MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/en_us.l DEPENDS langtool
- )
-else(WIN32)
+endif(NOT GREP OR NOT PERL)
+
+# If grep exists, use it to generate the index file
+if(GREP)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/index
COMMAND ${GREP} '^[A-Z]' ${CMAKE_CURRENT_SOURCE_DIR}/en_us.l > ${CMAKE_CURRENT_BINARY_DIR}/index
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/en_us.l
)
-endif(WIN32)
-#add_custom_target(lang_index DEPENDS ${BUILD_DIR}/index)
-
-#add_custom_target(language)
+# Otherwise, use langtool to generate the index file
+else(GREP)
+ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/index
+ COMMAND langtool index ${CMAKE_CURRENT_SOURCE_DIR}/en_us.l ${CMAKE_CURRENT_BINARY_DIR}/index
+ MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/en_us.l DEPENDS langtool
+ )
+endif(GREP)
-set(LANG_SRCS cat.l de.l en_us.l es.l fr.l gr.l hun.l it.l nl.l pl.l pt.l ru.l tr.l)
+# Find all the *.l files within the current source directory, and sort the list
+file(GLOB LANG_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.l")
list(SORT LANG_SRCS)
+# Iterate through the language files
foreach(LANG_L ${LANG_SRCS})
+ # Convert the language file's extension to have no extension
STRING(REGEX REPLACE "\\.l$" "" LANG ${LANG_L})
- #set(LANGS ${LANGS} ${BUILD_DIR}/${LANG})
- set(LANGS ${LANGS} ${CMAKE_CURRENT_BINARY_DIR}/${LANG})
- #add_custom_command(OUTPUT ${BUILD_DIR}/${LANG}
- # COMMAND langcomp ${LANG_L}
- # MAIN_DEPENDENCY ${LANG_L} DEPENDS langcomp ${BUILD_DIR}/index
- #)
+ # Add the language file to the list of compiled language files
+ list(APPEND LANGS ${CMAKE_CURRENT_BINARY_DIR}/${LANG})
+ # Generate a compiled language file using langcomp, as well as having a dependency on the index file being generated
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${LANG}
- #CMMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${LANG_L} ${CMAKE_CURRENT_BINARY_DIR}/
COMMAND langcomp ${CMAKE_CURRENT_SOURCE_DIR}/${LANG_L} ${CMAKE_CURRENT_BINARY_DIR}/${LANG}
- #COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/${LANG_L}
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/${LANG_L} DEPENDS langcomp ${CMAKE_CURRENT_BINARY_DIR}/index
)
- #add_custom_target(lang_${LANG} ALL DEPENDS ${BUILD_DIR}/${LANG})
- #add_custom_target(lang_${LANG} DEPENDS ${BUILD_DIR}/${LANG})
- #add_dependencies(language lang_${LANG})
- #add_dependencies(language ${BUILD_DIR}/${LANG})
endforeach(LANG_L)
-#add_custom_command(OUTPUT ${BUILD_DIR}/language.h
-# COMMAND ${PERL} -e < ${BUILD_DIR}/index > ${BUILD_DIR}/language.h 'print STDERR \"Generating language.h... \"\; $$i=0\; while \(<>\) { chop\; printf \"\#define %-32s %d\\n\", $$_, $$i++\; } print \"\\n\#define NUM_STRINGS $$i\\n\"\; print STDERR \"$$i strings\\n\"\;'
-# COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_DIR}/language.h ${Anope_SOURCE_DIR}/include/
-# MAIN_DEPENDENCY ${BUILD_DIR}/index
-#)
-if(WIN32)
- add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/language.h
- COMMAND langtool language.h ${CMAKE_CURRENT_BINARY_DIR}/index ${CMAKE_CURRENT_BINARY_DIR}/language.h
- MAIN_DEPENDENCY ${CMAKE_CURRENT_BINARY_DIR}/index DEPENDS langtool
- )
-else(WIN32)
+# If perl exists (and we aren't using Visual Studio, it hates this), use it to generate language.h
+if(NOT MSVC AND PERL)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/language.h
COMMAND ${PERL} -e < ${CMAKE_CURRENT_BINARY_DIR}/index > ${CMAKE_CURRENT_BINARY_DIR}/language.h 'print STDERR \"Generating language.h... \"\; $$i=0\; while \(<>\) { chop\; printf \"\#define %-32s %d\\n\", $$_, $$i++\; } print \"\\n\#define NUM_STRINGS $$i\\n\"\; print STDERR \"$$i strings\\n\"\;'
- #COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/language.h ${Anope_SOURCE_DIR}/include/
MAIN_DEPENDENCY ${CMAKE_CURRENT_BINARY_DIR}/index
)
-endif(WIN32)
-#add_custom_target(lang_language_h DEPENDS ${BUILD_DIR}/language.h)
-#add_dependencies(language lang_language_h)
-#add_dependencies(language ${BUILD_DIR}/language.h)
-#add_custom_target(language DEPENDS ${LANGS} ${BUILD_DIR}/language.h)
+# Otherwise, use langtool to generate language.h
+else(NOT MSVC AND PERL)
+ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/language.h
+ COMMAND langtool language.h ${CMAKE_CURRENT_BINARY_DIR}/index ${CMAKE_CURRENT_BINARY_DIR}/language.h
+ MAIN_DEPENDENCY ${CMAKE_CURRENT_BINARY_DIR}/index DEPENDS langtool
+ )
+endif(NOT MSVC AND PERL)
+
+# Add a custom target to depend on the language files and language.h
add_custom_target(language DEPENDS ${LANGS} ${CMAKE_CURRENT_BINARY_DIR}/language.h)
+# If RUNGROUP was set, make the permissions be to have owner read/write as well as group read/write
if(RUNGROUP)
set(PERMS OWNER_READ OWNER_WRITE GROUP_READ GROUP_WRITE)
+# Otherwise, only make the permissions be owner read/write
else(RUNGROUP)
set(PERMS OWNER_READ OWNER_WRITE)
endif(RUNGROUP)
+# Set the language files to be installed to the languages directory under the data directory
install(FILES ${LANGS}
DESTINATION "${DATADIR}/languages"
PERMISSIONS ${PERMS}
)
+
+# On non-Windows platforms, if RUNGROUP is set, change the permissions of the languages directory
if(NOT WIN32)
if(RUNGROUP)
- #install(CODE "execute_process(COMMAND ${CHGRP} -R ${RUNGROUP} \"${DATADIR}/languages\")")
- install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"${DATADIR}/languages\")")
+ install(CODE "execute_process(COMMAND ${CHMOD} 2770 \"${DATADIR}/languages\")")
else(RUNGROUP)
install(CODE "execute_process(COMMAND ${CHMOD} 0700 \"${DATADIR}/languages\")")
endif(RUNGROUP)