Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cmake] Small improvements and fixes #10078

Merged
merged 5 commits into from
Jul 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions project/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ set(CORE_BUILD_DIR build)

message(STATUS "Source directory: ${CORE_SOURCE_DIR}")
message(STATUS "Build directory: ${CMAKE_BINARY_DIR}")
if(CMAKE_BINARY_DIR STREQUAL CORE_SOURCE_DIR)
message(WARNING "In-source build detected. It is recommended to build out-of-source.")
endif()

include(modules/extra/ECMEnableSanitizers.cmake)
include(scripts/common/GeneratorSetup.cmake)
Expand Down
7 changes: 7 additions & 0 deletions project/cmake/scripts/common/ArchSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ endif()
set(CORE_MAIN_SOURCE ${CORE_SOURCE_DIR}/xbmc/platform/posix/main.cpp)

# system specific arch setup
if(NOT EXISTS ${PROJECT_SOURCE_DIR}/scripts/${CORE_SYSTEM_NAME}/ArchSetup.cmake)
message(FATAL_ERROR "Couldn't find configuration for '${CORE_SYSTEM_NAME}' "
"Either the platform is not (yet) supported "
"or a toolchain file has to be specified. "
"Consult ${CMAKE_SOURCE_DIR}/README.md for instructions. "
"Note: Specifying a toolchain requires a clean build directory!")
endif()
include(${PROJECT_SOURCE_DIR}/scripts/${CORE_SYSTEM_NAME}/ArchSetup.cmake)

message(STATUS "Core system type: ${CORE_SYSTEM_NAME}")
Expand Down
54 changes: 54 additions & 0 deletions project/cmake/scripts/common/CMakeHelpers.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# This file contains functions that support the debugging of the CMake files.

# This file shouldn't be included per default in any CMake file. It should be
# included and used only on demand. All functions are prefixed with "debug_".
#
# Usage:
# include(scripts/common/CMakeHelpers.cmake)
# debug_print_variables()

# Print all CMake variables.
macro(debug_print_variables)
get_cmake_property(_variableNames VARIABLES)
foreach(_variableName ${_variableNames})
message(STATUS "${_variableName} = ${${_variableName}}")
endforeach()
endmacro()

# Get all properties that CMake supports and convert them to a list.
function(debug_get_properties VAR)
execute_process(COMMAND cmake --help-property-list
OUTPUT_VARIABLE _properties)
string(REGEX REPLACE ";" "\\\\;" _properties "${_properties}")
string(REGEX REPLACE "\n" ";" _properties "${_properties}")
list(REMOVE_DUPLICATES _properties)
list(REMOVE_ITEM _properties LOCATION)
set(${VAR} ${_properties} PARENT_SCOPE)
endfunction()

# List all properties.
function(debug_list_properties)
debug_get_properties(_properties)
message("CMake properties = ${_properties}")
endfunction()

# Print all set properties of a specified target.
function(debug_print_target_properties target)
if(NOT TARGET ${target})
message(FATAL_ERROR "There is no target named '${target}'")
endif()

debug_get_properties(_properties)

# Reading LOCATION property is deprecated and triggers a fatal error.
string(REGEX REPLACE ";LOCATION;|LOCATION" "" _properties "${_properties}")
string(REGEX REPLACE "<CONFIG>" "${CMAKE_BUILD_TYPE}" _properties
"${_properties}")
foreach(_property ${_properties})
get_property(_value TARGET ${target} PROPERTY ${_property} SET)
if(_value)
get_target_property(_value ${target} ${_property})
message("${target} ${_property} = ${_value}")
endif()
endforeach()
endfunction()
15 changes: 15 additions & 0 deletions project/cmake/scripts/common/GeneratorSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ else()
message(STATUS "Generator: Single-configuration: ${CMAKE_BUILD_TYPE} (${CMAKE_GENERATOR})")
endif()

# Print CMake version
message(STATUS "CMake Version: ${CMAKE_VERSION}")

# Deal with CMake special cases
if(CMAKE_VERSION VERSION_EQUAL 3.5.1)
message(WARNING "CMake 3.5.1 introduced a crash during configuration. "
"Please consider upgrading to 3.5.2 (cmake.org/Bug/view.php?id=16044)")
endif()

# Darwin needs CMake 3.4
if(APPLE AND CMAKE_VERSION VERSION_LESS 3.4)
message(WARNING "Build on Darwin requires CMake 3.4 or later (tdb library support) "
"or the usage of the patched version in depends.")
endif()

# Ninja needs CMake 3.2 due to ExternalProject BUILD_BYPRODUCTS usage
if(CMAKE_GENERATOR STREQUAL Ninja AND CMAKE_VERSION VERSION_LESS 3.2)
message(FATAL_ERROR "Generator: Ninja requires CMake 3.2 or later")
Expand Down
16 changes: 10 additions & 6 deletions project/cmake/scripts/common/Macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,21 @@ function(copy_file_to_buildtree file relative)
string(REPLACE "${relative}/" "" outfile ${file})
get_filename_component(outdir ${outfile} DIRECTORY)

if(NOT TARGET export-files)
file(REMOVE ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake)
add_custom_target(export-files ALL COMMENT "Copying files into build tree"
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake)
endif()
if(NOT ${CORE_SOURCE_DIR} MATCHES ${CMAKE_BINARY_DIR})
if(NOT CMAKE_BINARY_DIR STREQUAL CORE_SOURCE_DIR)
if(NOT TARGET export-files)
file(REMOVE ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake)
add_custom_target(export-files ALL COMMENT "Copying files into build tree"
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake)
endif()
if(VERBOSE)
message(STATUS "copy_file_to_buildtree - copying file: ${file} -> ${CMAKE_BINARY_DIR}/${outfile}")
endif()
file(APPEND ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/ExportFiles.cmake
"file(COPY \"${file}\" DESTINATION \"${CMAKE_BINARY_DIR}/${outdir}\")\n")
else()
if(NOT TARGET export-files)
add_custom_target(export-files ALL)
endif()
endif()
if(NOT arg_NO_INSTALL)
list(APPEND install_data ${outfile})
Expand Down
5 changes: 3 additions & 2 deletions xbmc/cores/VideoPlayer/VideoRenderers/ColorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <math.h>
#include <string>
#include <vector>

#include "system.h"
#include "ColorManager.h"
Expand Down Expand Up @@ -305,8 +306,8 @@ bool CColorManager::Load3dLut(const std::string filename, uint16_t **CLUT, int *

for (int rIndex=0; rIndex<rSize; rIndex++) {
for (int gIndex=0; gIndex<gSize; gIndex++) {
uint16_t input[bSize*3];
lutFile.Read(input, 3*bSize*sizeof(uint16_t));
std::vector<uint16_t> input(bSize*3);
lutFile.Read(input.data(), input.size()*sizeof(input[0]));
int index = (rIndex + gIndex*rSize)*3;
for (int bIndex=0; bIndex<bSize; bIndex++) {
(*CLUT)[index+bIndex*rSize*gSize*3+0] = input[bIndex*3+2];
Expand Down