diff options
author | cyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-03-02 01:33:47 +0000 |
---|---|---|
committer | cyberbotx <cyberbotx@5417fbe8-f217-4b02-8779-1006273d7864> | 2009-03-02 01:33:47 +0000 |
commit | c6f4b951317ad3c78844359742de66ce63210ef0 (patch) | |
tree | a990f1aea84132625830d3cca72c454dd7fb0dae /src | |
parent | 6794273f7d44987b061f038bc3c7909fa64a86d5 (diff) |
Added a strip_string function to Anope.cmake, cleaned up other parts of Anope.cmake, added better find function for #include lines, added functionality for CMake to auto-detect includes in non-standard locations.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2139 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 15 | ||||
-rw-r--r-- | src/core/CMakeLists.txt | 17 | ||||
-rw-r--r-- | src/modules/CMakeLists.txt | 29 | ||||
-rw-r--r-- | src/protocol/CMakeLists.txt | 17 |
4 files changed, 68 insertions, 10 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6e700db49..d1cc3d832 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,11 +17,24 @@ endif(CMAKE244_OR_BETTER) # Set all the files to use C++ as well as set their compile flags (use the module-specific compile flags, though) set_source_files_properties(${SRC_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}") +# Create an empty list to store extra include directories +set(EXTRA_INCLUDES) # Iterate through all the source files foreach(SRC ${SRC_SRCS}) + # Temporary variable for the current source's include directories + set(TEMP_INCLUDES) # Calculate the header file dependencies for the given source file - calculate_depends(${SRC}) + calculate_depends(${SRC} TEMP_INCLUDES) + # If there were some extra include directories, add them to the list + if(TEMP_INCLUDES) + append_to_list(EXTRA_INCLUDES ${TEMP_INCLUDES}) + endif(TEMP_INCLUDES) endforeach(SRC) +# If there were extra include directories, remove the duplicates and add the directories to the include path +if(EXTRA_INCLUDES) + remove_list_duplicates(EXTRA_INCLUDES) + include_directories(${EXTRA_INCLUDES}) +endif(EXTRA_INCLUDES) # Under Windows, we also include a resource file to the build if(WIN32) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 0a3655806..ba1032f72 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -14,12 +14,21 @@ endif(WIN32) # Set all the files to use C++ as well as set their compile flags (use the module-specific compile flags, though) set_source_files_properties(${CORE_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}") +# Create an empty list to store extra include directories +set(EXTRA_INCLUDES) + # Iterate through all the source files foreach(SRC ${CORE_SRCS}) # Convert the source file extension to have a .so extension string(REGEX REPLACE "\\.(c|cpp)$" ".so" SO ${SRC}) + # Temporary variable for the current source's include directories + set(TEMP_INCLUDES) # Calculate the header file dependencies for the given source file - calculate_depends(${SRC}) + calculate_depends(${SRC} TEMP_INCLUDES) + # If there were some extra include directories, add them to the list + if(TEMP_INCLUDES) + append_to_list(EXTRA_INCLUDES ${TEMP_INCLUDES}) + endif(TEMP_INCLUDES) # For Visual Studio only, include win32_memory.cpp to the list of sources, required to override Visual Studio's overrides of the new/delete operators if(MSVC) append_to_list(SRC ${Anope_SOURCE_DIR}/src/win32_memory.cpp) @@ -39,3 +48,9 @@ foreach(SRC ${CORE_SRCS}) DESTINATION data/modules ) endforeach(SRC) + +# If there were extra include directories, remove the duplicates and add the directories to the include path +if(EXTRA_INCLUDES) + remove_list_duplicates(EXTRA_INCLUDES) + include_directories(${EXTRA_INCLUDES}) +endif(EXTRA_INCLUDES) diff --git a/src/modules/CMakeLists.txt b/src/modules/CMakeLists.txt index 3f1144c6f..65959b174 100644 --- a/src/modules/CMakeLists.txt +++ b/src/modules/CMakeLists.txt @@ -14,12 +14,21 @@ endif(WIN32) # Set all the files to use C++ as well as set their compile flags (use the module-specific compile flags, though) set_source_files_properties(${MODULES_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}") +# Create an empty list to store extra include directories +set(EXTRA_INCLUDES) + # Iterate through all the source files foreach(SRC ${MODULES_SRCS}) # Convert the source file extension to have a .so extension string(REGEX REPLACE "\\.(c|cpp)$" ".so" SO ${SRC}) + # Temporary variable for the current source's include directories + set(TEMP_INCLUDES) # Calculate the header file dependencies for the given source file - calculate_depends(${SRC}) + calculate_depends(${SRC} TEMP_INCLUDES) + # If there were some extra include directories, add them to the list + if(TEMP_INCLUDES) + append_to_list(EXTRA_INCLUDES ${TEMP_INCLUDES}) + endif(TEMP_INCLUDES) # Set up a temporary LDFLAGS for this file set(THIS_LDFLAGS "${LDFLAGS}") # Reset extra dependencies @@ -39,11 +48,11 @@ foreach(SRC ${MODULES_SRCS}) # Iterate through the libraries given foreach(LIBRARY ${REQUIRED_LIBRARY}) # Locate the library to see if it exists - if(MSVC AND WSDK_PATH) - find_library(FOUND_${LIBRARY}_LIBRARY NAMES ${LIBRARY} PATHS ${WSDK_PATH}/lib) - else(MSVC AND WSDK_PATH) + if(DEFAULT_LIBRARY_DIRS OR WSDK_PATH) + find_library(FOUND_${LIBRARY}_LIBRARY NAMES ${LIBRARY} PATHS ${DEFAULT_LIBRARY_DIRS} ${WSDK_PATH}/lib) + else(DEFAULT_LIBRARY_DIRS OR WSDK_PATH) find_library(FOUND_${LIBRARY}_LIBRARY NAMES ${LIBRARY}) - endif(MSVC AND WSDK_PATH) + endif(DEFAULT_LIBRARY_DIRS OR WSDK_PATH) # If the library was found, we will add it to the linker flags if(FOUND_${LIBRARY}_LIBRARY) # Get the path only of the library, to add it to linker flags @@ -58,7 +67,7 @@ foreach(SRC ${MODULES_SRCS}) endif(MSVC) else(FOUND_${LIBRARY}_LIBRARY) # In the case of the library not being found, we fatally error so CMake stops trying to generate - message(FATAL_ERROR "${SRC} need library ${LIBRARY} but we were unable to locate that library! Check that the library is within the search path of your OS.") + message(FATAL_ERROR "${SRC} needs library ${LIBRARY} but we were unable to locate that library! Check that the library is within the search path of your OS.") endif(FOUND_${LIBRARY}_LIBRARY) endforeach(LIBRARY) endforeach(REQUIRED_LIBRARY) @@ -77,7 +86,7 @@ foreach(SRC ${MODULES_SRCS}) endif(LIBRARIES) # Iterate through library paths and add them to the linker flags foreach(LIBRARY_PATH ${LIBRARY_PATHS}) - find_in_list(DEFAULT_LIBRARY_DIRS ${LIBRARY_PATH} FOUND_IN_DEFAULTS) + find_in_list(DEFAULT_LIBRARY_DIRS "${LIBRARY_PATH}" FOUND_IN_DEFAULTS) if(FOUND_IN_DEFAULTS EQUAL -1) set(THIS_LDFLAGS "${THIS_LDFLAGS} -L${LIBRARY_PATH}") endif(FOUND_IN_DEFAULTS EQUAL -1) @@ -100,3 +109,9 @@ foreach(SRC ${MODULES_SRCS}) DESTINATION data/modules ) endforeach(SRC) + +# If there were extra include directories, remove the duplicates and add the directories to the include path +if(EXTRA_INCLUDES) + remove_list_duplicates(EXTRA_INCLUDES) + include_directories(${EXTRA_INCLUDES}) +endif(EXTRA_INCLUDES) diff --git a/src/protocol/CMakeLists.txt b/src/protocol/CMakeLists.txt index dc8d40126..c903545c3 100644 --- a/src/protocol/CMakeLists.txt +++ b/src/protocol/CMakeLists.txt @@ -14,12 +14,21 @@ endif(WIN32) # Set all the files to use C++ as well as set their compile flags (use the module-specific compile flags, though) set_source_files_properties(${PROTOCOL_SRCS} PROPERTIES LANGUAGE CXX COMPILE_FLAGS "${CXXFLAGS}") +# Create an empty list to store extra include directories +set(EXTRA_INCLUDES) + # Iterate through all the source files foreach(SRC ${PROTOCOL_SRCS}) # Convert the source file extension to have a .so extension string(REGEX REPLACE "\\.(c|cpp)$" ".so" SO ${SRC}) + # Temporary variable for the current source's include directories + set(TEMP_INCLUDES) # Calculate the header file dependencies for the given source file - calculate_depends(${SRC}) + calculate_depends(${SRC} TEMP_INCLUDES) + # If there were some extra include directories, add them to the list + if(TEMP_INCLUDES) + append_to_list(EXTRA_INCLUDES ${TEMP_INCLUDES}) + endif(TEMP_INCLUDES) # For Visual Studio only, include win32_memory.cpp to the list of sources, required to override Visual Studio's overrides of the new/delete operators if(MSVC) append_to_list(SRC ${Anope_SOURCE_DIR}/src/win32_memory.cpp) @@ -39,3 +48,9 @@ foreach(SRC ${PROTOCOL_SRCS}) DESTINATION data/modules ) endforeach(SRC) + +# If there were extra include directories, remove the duplicates and add the directories to the include path +if(EXTRA_INCLUDES) + remove_list_duplicates(EXTRA_INCLUDES) + include_directories(${EXTRA_INCLUDES}) +endif(EXTRA_INCLUDES) |