Feature/cmake cleanup (#727)

* Sweeping CMake cleanup
* Cleaning up message log in CMake
This commit is contained in:
Alexander Bock
2018-09-21 14:25:51 -04:00
committed by GitHub
parent a91eeb11f0
commit 0ca84d91f1
21 changed files with 200 additions and 199 deletions

View File

@@ -25,8 +25,6 @@
include(${OPENSPACE_CMAKE_EXT_DIR}/global_variables.cmake)
function (create_new_application application_name)
message(STATUS "Configuring application ${application_name}")
add_executable(${application_name} MACOSX_BUNDLE ${ARGN})
set_openspace_compile_settings(${application_name})

View File

@@ -29,7 +29,26 @@ function (handle_applications)
# Remove the .DS_Store present on Mac
list(REMOVE_ITEM appDirs ".DS_Store")
message(STATUS "Configuration application")
# Print all the enabled modules
# message(STATUS "Enabled modules:")
# list(LENGTH enabled_module_names enabled_module_count)
# math(EXPR enabled_module_count "${enabled_module_count} - 1")
# foreach (val RANGE ${enabled_module_count})
# list(GET enabled_module_names ${val} name)
# list(GET enabled_module_paths ${val} path)
# message(STATUS "\t${name} (${path})")
# endforeach ()
message(STATUS "Enabled applications:")
foreach (app ${appDirs})
string(TOUPPER ${app} upper_app)
if (OPENSPACE_APPLICATION_${upper_app})
message(STATUS "\t${app} (${OPENSPACE_APPS_DIR}/${app})")
endif ()
endforeach ()
# First create all of the options for the applications. In case that one of the
# applications fail to include later, we still want all of them listed
foreach (app ${appDirs})
@@ -44,8 +63,9 @@ function (handle_applications)
set(app_dir "${OPENSPACE_APPS_DIR}/${app}")
string(TOUPPER ${app} upper_app)
if (OPENSPACE_APPLICATION_${upper_app})
message(STATUS "Adding application ${app}")
begin_header("Application: ${app}")
add_subdirectory(${app_dir})
end_header("End: Application: ${app}")
endif ()
endforeach ()
endfunction()

View File

@@ -23,6 +23,7 @@
##########################################################################################
include(${OPENSPACE_CMAKE_EXT_DIR}/global_variables.cmake)
include(${GHOUL_BASE_DIR}/support/cmake/message_macros.cmake)
function (handle_modules internal_module_path external_modules_paths)
#
@@ -45,16 +46,8 @@ function (handle_modules internal_module_path external_modules_paths)
set(all_module_paths ${all_module_paths} ${paths})
endforeach ()
list(LENGTH all_module_names len1)
math(EXPR len2 "${len1} - 1")
# Debug: List all modules
# message(STATUS "All modules:")
# foreach (val RANGE ${len2})
# list(GET all_module_names ${val} name)
# list(GET all_module_paths ${val} path)
# message(STATUS "\t${name} (${path})")
# endforeach ()
list(LENGTH all_module_names all_module_names_count)
math(EXPR all_module_names_count "${all_module_names_count} - 1")
#
# Step 2: Create options for all modules with correct default values
@@ -62,13 +55,13 @@ function (handle_modules internal_module_path external_modules_paths)
set(enabled_module_names "")
set(enabled_module_paths "")
foreach(val RANGE ${len2})
foreach(val RANGE ${all_module_names_count})
list(GET all_module_names ${val} name)
list(GET all_module_paths ${val} path)
get_module_attribute_supported(${path} is_module_supported)
if (NOT ${is_module_supported})
message(STATUS "Skipping module ${path} as it is not supported on this machine")
message(STATUS "Skipping module ${name} (${path}) as it is not supported on this machine")
continue()
endif ()
@@ -86,9 +79,9 @@ function (handle_modules internal_module_path external_modules_paths)
# Step 3: For each module that is default or enabled by the user, get the dependencies
#
set(dependencies "")
list(LENGTH enabled_module_names len1)
math(EXPR len2 "${len1} - 1")
foreach (val RANGE ${len2})
list(LENGTH enabled_module_names enabled_module_count)
math(EXPR enabled_module_count "${enabled_module_count} - 1")
foreach (val RANGE ${enabled_module_count})
list(GET enabled_module_names ${val} name)
list(GET enabled_module_paths ${val} path)
@@ -123,35 +116,38 @@ function (handle_modules internal_module_path external_modules_paths)
# Print all the enabled modules
message(STATUS "Enabled modules:")
list(LENGTH enabled_module_names len1)
math(EXPR len2 "${len1} - 1")
foreach (val RANGE ${len2})
list(LENGTH enabled_module_names enabled_module_count)
math(EXPR enabled_module_count "${enabled_module_count} - 1")
foreach (val RANGE ${enabled_module_count})
list(GET enabled_module_names ${val} name)
list(GET enabled_module_paths ${val} path)
message(STATUS "\t${name} (${path})")
message(STATUS "\t${name} (${path})")
endforeach ()
#
# Step 5: Add the subdirectories of all the enabled modules
# Step 5: Add the subdirectories of all enabled modules
#
set(module_class_names "")
set(module_external_libraries "")
foreach (val RANGE ${len2})
foreach (val RANGE ${enabled_module_count})
list(GET enabled_module_names ${val} name)
list(GET enabled_module_paths ${val} path)
create_library_name(${name} library_name)
begin_header("Module ${name} (${library_name})")
add_subdirectory(${path})
end_header("End: Module ${name}")
message(STATUS "")
# Only link libOpenSpace against the library if it has been set STATIC
# Only link openspace-core against the library if it has been set STATIC
get_target_property(library_type ${library_name} TYPE)
if (NOT ${library_type} STREQUAL "SHARED_LIBRARY")
target_link_libraries(libOpenSpace ${library_name})
target_link_libraries(openspace-core ${library_name})
endif()
create_define_name(${name} define_name)
target_compile_definitions(libOpenSpace PUBLIC "${define_name}")
target_compile_definitions(openspace-core PUBLIC "${define_name}")
get_property(class_name GLOBAL PROPERTY CurrentModuleClassName)
list(APPEND module_class_names ${class_name})
@@ -170,7 +166,7 @@ function (handle_modules internal_module_path external_modules_paths)
set(MODULE_HEADERS "")
set(MODULE_CLASSES "")
set(MODULE_PATHS "")
foreach (val RANGE ${len2})
foreach (val RANGE ${enabled_module_count})
list(GET enabled_module_names ${val} name)
list(GET enabled_module_paths ${val} path)
list(GET module_class_names ${val} class_name)
@@ -195,7 +191,7 @@ function (handle_modules internal_module_path external_modules_paths)
# The module path should include the 'modules' directory, which is removed for the
# include path to make all of the includes look the same
list(APPEND MODULE_PATHS " \"${path}/modules\",\n")
target_include_directories(libOpenSpace PUBLIC ${path})
target_include_directories(openspace-core PUBLIC ${path})
endforeach ()
if (NOT "${MODULE_HEADERS}" STREQUAL "")

View File

@@ -38,8 +38,6 @@ function (create_new_module module_name output_library_name library_mode)
# Create a library name of the style: openspace-module-${name}
create_library_name(${module_name} library_name)
message(STATUS "Configuring module ${module_name}: ${library_name}")
# Add the module files to the list of sources
get_module_files(${module_name} module_files)
@@ -105,7 +103,7 @@ endfunction ()
# External dependencies are found using the find_package function and then linked
function (handle_module_dependencies target_name module_name)
# We always want to link against Ghoul and the core library
target_link_libraries(${library_name} Ghoul libOpenSpace)
target_link_libraries(${library_name} Ghoul openspace-core)
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/include.cmake")
include(${CMAKE_CURRENT_SOURCE_DIR}/include.cmake)