1# USAGE:
2# CreateCompileGroup(
3#     <group name>
4#     <brief description>
5#     <library_name>
6#     <other compile group dependencies>
7#     <required dependencies>
8#     <optional dependencies>
9#     <source file 1>
10#     <source file 2>
11#     ...
12#     <source file N>
13# )
14
15# Specify a group of sources files, as well their dependencies, and ultimate target library.
16function(CreateCompileGroup
17         GROUP_NAME
18	       DESCRIPTION
19	       LIBRARY_NAME
20	       GROUP_DEPENDENCIES
21	       REQUIRED_DEPENDENCIES
22	       OPTIONAL_DEPENDENCIES)
23
24  option(MUQ_ENABLEGROUP_${GROUP_NAME} "Should the group ${GROUP_NAME} be compiled?" ${MUQ_ENABLEGROUP_DEFAULT})
25
26  message(STATUS "MUQ_ENABLEGROUP_${GROUP_NAME} = ${MUQ_ENABLEGROUP_${GROUP_NAME}}")
27  set(MUQ_GROUPS "${MUQ_GROUPS};${GROUP_NAME}" CACHE INTERNAL "A list of all of the muq groups.")
28
29  set(${GROUP_NAME}_REQUIRES_GROUPS ${GROUP_DEPENDENCIES} CACHE INTERNAL "Other compile groups that are required by the ${GROUP_NAME} group.")
30
31  set(${GROUP_NAME}_REQUIRES ${REQUIRED_DEPENDENCIES} CACHE INTERNAL "External packages required by the ${GROUP_NAME} compile group.")
32  set(${GROUP_NAME}_DESIRES ${OPTIONAL_DEPENDENCIES} CACHE INTERNAL "External packages that the ${GROUP_NAME} compile group can exploit if they're available.")
33
34  set(${GROUP_NAME}_LIBRARY ${LIBRARY_NAME} CACHE INTERNAL "The library this group will contribute to.")
35
36  # Compute the path to the source file relative to the root directory
37  string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/"  ""  RELATIVE_DIR ${CMAKE_CURRENT_LIST_DIR})
38
39  set(SOURCES )
40  foreach(source ${ARGN})
41    list(APPEND SOURCES "${RELATIVE_DIR}/${source}")
42  endforeach()
43
44  set(${GROUP_NAME}_SOURCES ${SOURCES} CACHE INTERNAL "Source files included in the ${GROUP_NAME} compile group.")
45
46endfunction(CreateCompileGroup)
47
48
49
50# Used to add a collection of test files that are linked to a compile group specified with CreateCompileGroup
51function(CreateTestGroup GROUP_NAME)
52
53  set(MUQ_TEST_GROUPS "${MUQ_TEST_GROUPS};${GROUP_NAME}" CACHE INTERNAL "A list of all of the muq test groups.")
54
55  # Compute the path to the source file relative to the root directory
56  string(REPLACE "${CMAKE_SOURCE_DIR}/"  ""  RELATIVE_DIR ${CMAKE_CURRENT_LIST_DIR})
57
58  set(SOURCES )
59  foreach(source ${ARGN})
60    list(APPEND SOURCES "${RELATIVE_DIR}/${source}")
61  endforeach()
62
63  set(${GROUP_NAME}_TEST_SOURCES ${SOURCES} CACHE INTERNAL "Source files with tests related to the ${GROUP_NAME} compile group.")
64
65endfunction(CreateTestGroup)
66
67# Used to add a collection of test files that are linked to a compile group specified with CreateCompileGroup
68function(CreateParallelTestGroup GROUP_NAME)
69
70  set(MUQ_PARALLEL_TEST_GROUPS "${MUQ_PARALLEL_TEST_GROUPS};${GROUP_NAME}" CACHE INTERNAL "A list of all of the muq parallel test groups.")
71
72  # Compute the path to the source file relative to the root directory
73  string(REPLACE "${CMAKE_SOURCE_DIR}/"  ""  RELATIVE_DIR ${CMAKE_CURRENT_LIST_DIR})
74
75  set(SOURCES )
76  foreach(source ${ARGN})
77    list(APPEND SOURCES "${RELATIVE_DIR}/${source}")
78  endforeach()
79
80  set(${GROUP_NAME}_PARALLEL_TEST_SOURCES ${SOURCES} CACHE INTERNAL "Source files with parallel tests related to the ${GROUP_NAME} compile group.")
81
82endfunction(CreateTestGroup)
83