diff --git a/Base/CMakeLists.txt b/Base/CMakeLists.txt index eeec59b6b1204e40aae59c0f85a9fde16cf6b9b7..f7ee7316a5aa170c34356a18eb6b8e8ae5fe43ef 100644 --- a/Base/CMakeLists.txt +++ b/Base/CMakeLists.txt @@ -1,29 +1,9 @@ # Source files -SET ( Base_Files - binarySearch.h - Configure.h.in - CPUTimeTimer.h - DateTools.h - FileFinder.h - FileTools.h - printList.h - quicksort.h - RunTimeTimer.h - StringTools.h - swap.h - TimeMeasurementBase.h - uniqueListInsert.h - wait.h - binarySearch.cpp - DateTools.cpp - CPUTimeTimer.cpp - RunTimeTimer.cpp - StringTools.cpp -) -SOURCE_GROUP( Base FILES ${Base_Files}) + +GET_SOURCE_FILES(SOURCES) # Create the library -ADD_LIBRARY( Base STATIC ${Base_Files}) +ADD_LIBRARY( Base STATIC ${SOURCES}) SET_TARGET_PROPERTIES(Base PROPERTIES LINKER_LANGUAGE CXX) diff --git a/CMakeLists.txt b/CMakeLists.txt index 247e4f1e9ddef794ef60ece651c031ff6e073157..be4e00de9a76ec6cae27b833930534b62ead278c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ cmake_minimum_required(VERSION 2.6) project( OGS-6 ) ### CMake includes ### +INCLUDE(scripts/cmake/Functions.cmake) INCLUDE(scripts/cmake/CMakeSetup.cmake) INCLUDE(scripts/cmake/CompilerSetup.cmake) INCLUDE(scripts/cmake/Find.cmake) diff --git a/scripts/cmake/Functions.cmake b/scripts/cmake/Functions.cmake new file mode 100644 index 0000000000000000000000000000000000000000..1a88d30f43efe903c9603be03593ab99461e37d1 --- /dev/null +++ b/scripts/cmake/Functions.cmake @@ -0,0 +1,27 @@ +# Returns the current subdirectory in the sources directory. +MACRO(GET_CURRENT_SOURCE_SUBDIRECTORY CURRENT_SOURCE_SUBDIRECTORY) + STRING(REGEX REPLACE ".*/([^/]*)" "\\1" REGEX_RESULT "${CMAKE_CURRENT_SOURCE_DIR}" ) + SET(${CURRENT_SOURCE_SUBDIRECTORY} ${REGEX_RESULT}) +ENDMACRO() + +# Returns a list of source files (*.h and *.cpp) in SOURCE_FILES and creates a Visual +# Studio folder. A (relative) directory can be passed as second parameter (optional). +MACRO(GET_SOURCE_FILES SOURCE_FILES) + + IF(ARGC EQUAL 2) + SET(DIR "${arg2}/") + ELSE() + SET(DIR "") + ENDIF() + + # Get all files in the directory + FILE(GLOB GET_SOURCE_FILES_HEADERS ${DIR}*.h) + FILE(GLOB GET_SOURCE_FILES_SOURCES ${DIR}*.cpp) + + SET(${SOURCE_FILES} ${GET_SOURCE_FILES_HEADERS} ${GET_SOURCE_FILES_SOURCES}) + + GET_CURRENT_SOURCE_SUBDIRECTORY(DIRECTORY) + MESSAGE("Curr: ${DIRECTORY}") + SOURCE_GROUP( ${DIRECTORY} FILES ${SOURCE_FILES}) + +ENDMACRO() \ No newline at end of file