diff options
Diffstat (limited to 'lang')
| -rw-r--r-- | lang/CMakeLists.txt | 55 |
1 files changed, 47 insertions, 8 deletions
diff --git a/lang/CMakeLists.txt b/lang/CMakeLists.txt index c2933ddac..7d19d9bdf 100644 --- a/lang/CMakeLists.txt +++ b/lang/CMakeLists.txt @@ -3,15 +3,40 @@ set_source_files_properties(langcomp.c PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${ # Generate langcomp and set it's linker flags add_executable(langcomp langcomp.c) set_target_properties(langcomp PROPERTIES LINKER_LANGUAGE CXX LINK_FLAGS "${LDFLAGS}") +# Get the location of the binary to use later +get_target_property(langcomp_BINARY langcomp LOCATION) +if(IN_SOURCE) + # Add the executable to the list of files for CPack to ignore + file(RELATIVE_PATH langcomp_BINARY_RELATIVE ${Anope_BINARY_DIR} ${langcomp_BINARY}) + add_to_cpack_ignored_files("${langcomp_BINARY_RELATIVE}$" TRUE) +endif(IN_SOURCE) + +# Determine if langtool should be built +if(MSVC) + set(BUILD_LANGTOOL TRUE) +else(MSVC) + if(NOT GREP OR NOT PERL) + set(BUILD_LANGTOOL TRUE) + else(NOT GREP OR NOT PERL) + set(BUILD_LANGTOOL FALSE) + endif(NOT GREP OR NOT PERL) +endif(MSVC) # If grep or perl don't exist on the system, build langtool to generate index and language.h -if(NOT GREP OR NOT PERL) +if(BUILD_LANGTOOL) # 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 LINKER_LANGUAGE CXX LINK_FLAGS "${LDFLAGS}") -endif(NOT GREP OR NOT PERL) + # Get the location of the binary to use later) + get_target_property(langtool_BINARY langtool LOCATION) + if(IN_SOURCE) + # Add the executable to the list of files for CPack to ignore + file(RELATIVE_PATH langtool_BINARY_RELATIVE ${Anope_BINARY_DIR} ${langtool_BINARY}) + add_to_cpack_ignored_files("${langtool_BINARY_RELATIVE}$" TRUE) + endif(IN_SOURCE) +endif(BUILD_LANGTOOL) # If grep exists (and we aren't using Visual Studio, it hates this), use it to generate the index file if(NOT MSVC AND GREP) @@ -22,10 +47,15 @@ if(NOT MSVC AND GREP) # Otherwise, use langtool to generate the index file else(NOT MSVC AND GREP) add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/index - COMMAND ${CMAKE_CURRENT_BINARY_DIR}/langtool index ${CMAKE_CURRENT_SOURCE_DIR}/en_us.l ${CMAKE_CURRENT_BINARY_DIR}/index + COMMAND ${langtool_BINARY} 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(NOT MSVC AND GREP) +if(IN_SOURCE) + # Add the index file to the list of files for CPack to ignore + file(RELATIVE_PATH index_RELATIVE ${Anope_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/index) + add_to_cpack_ignored_files("${index_RELATIVE}$") +endif(IN_SOURCE) # Find all the *.l files within the current source directory, and sort the list file(GLOB LANG_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.l") @@ -41,9 +71,14 @@ foreach(LANG_L ${LANG_SRCS}) append_to_list(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} - COMMAND ${CMAKE_CURRENT_BINARY_DIR}/langcomp ${CMAKE_CURRENT_SOURCE_DIR}/${LANG_L} ${CMAKE_CURRENT_BINARY_DIR}/${LANG} + COMMAND ${langcomp_BINARY} ${CMAKE_CURRENT_SOURCE_DIR}/${LANG_L} ${CMAKE_CURRENT_BINARY_DIR}/${LANG} MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/${LANG_L} DEPENDS langcomp ${CMAKE_CURRENT_BINARY_DIR}/index ) + if(IN_SOURCE) + # Add the language file to the list of files for CPack to ignore + file(RELATIVE_PATH LANG_RELATIVE ${Anope_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${LANG}) + add_to_cpack_ignored_files("${LANG_RELATIVE}$") + endif(IN_SOURCE) endforeach(LANG_L) # If perl exists (and we aren't using Visual Studio, it hates this), use it to generate language.h @@ -55,10 +90,14 @@ if(NOT MSVC AND PERL) # Otherwise, use langtool to generate language.h else(NOT MSVC AND PERL) add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/language.h - COMMAND ${CMAKE_CURRENT_BINARY_DIR}/langtool language.h ${CMAKE_CURRENT_BINARY_DIR}/index ${CMAKE_CURRENT_BINARY_DIR}/language.h + COMMAND ${langtool_BINARY} 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) +if(IN_SOURCE) + # Add language.h to the list of files for CPack to ignore + add_to_cpack_ignored_files("language.h$" TRUE) +endif(IN_SOURCE) # 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) @@ -72,15 +111,15 @@ else(RUNGROUP) endif(RUNGROUP) # Set the language files to be installed to the languages directory under the data directory install(FILES ${LANGS} - DESTINATION "${DATADIR}/languages" + DESTINATION data/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 ${CHMOD} 2770 \"${DATADIR}/languages\")") + install(CODE "execute_process(COMMAND ${CHMOD} 2770 \"\${CMAKE_INSTALL_PREFIX}/data/languages\")") else(RUNGROUP) - install(CODE "execute_process(COMMAND ${CHMOD} 0700 \"${DATADIR}/languages\")") + install(CODE "execute_process(COMMAND ${CHMOD} 0700 \"\${CMAKE_INSTALL_PREFIX}/data/languages\")") endif(RUNGROUP) endif(NOT WIN32) |
