Commit abd5f8b1 authored by Florian Oetke's avatar Florian Oetke
Browse files

fixed mingw build

parent a2f32633
......@@ -11,6 +11,9 @@ function(mirrage_copy_recursive src dst)
else()
execute_process(
COMMAND ${CMAKE_COMMAND} -E make_directory "${dst}"
OUTPUT_QUIET
)
execute_process(
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${path}" "${dst}/"
OUTPUT_QUIET
)
......
......@@ -8,7 +8,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)
set(MIRRAGE_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${MIRRAGE_ROOT_DIR}/modules")
enable_language(C CXX ASM GLSL)
enable_language(C CXX ASM)
add_definitions(-DGSL_TERMINATE_ON_CONTRACT_VIOLATION)
......
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
# Automatically find the a suitable GLSL to SPIR-V compiler.
# By default it will look for a compiler as named by the CMAKE_GLSL_COMPILER_LIST
# variable. It can be overridden by setting:
#
# - CMAKE_GLSL_COMPILER: Name or full path of the GLSL compiler.
# e.g. my-glslc # Expected on the path
# e.g. /home/self/my-glslc
#
# - otherwise environment variable GLSL_COMPILER: Name or full path of the GLSL compiler
# e.g. my-glslc # Expected on the path
# e.g. /home/self/my-glslc
#
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake)
set(CMAKE_GLSL_COMPILER_ENV_VAR "GLSL_COMPILER")
# Name of GLSL compilers expected to be on the path.
set(CMAKE_GLSL_COMPILER_LIST glslc)
if(NOT CMAKE_GLSL_COMPILER)
set(CMAKE_GLSL_COMPILER_INIT NOTFOUND)
# Prefer the environment variable GLSL_COMPILER, and set
# CMAKE_GLSL_COMPILER_INIT if we find it.
if(NOT $ENV{GLSL_COMPILER} STREQUAL "")
get_filename_component(CMAKE_GLSL_COMPILER_INIT $ENV{GLSL_COMPILER} PROGRAM PROGRAM_ARGS CMAKE_GLSL_FLAGS_ENV_INIT)
if(CMAKE_GLSL_FLAGS_ENV_INIT)
set(CMAKE_GLSL_COMPILER_ARG1 "${CMAKE_GLSL_FLAGS_ENV_INIT}" CACHE STRING "First argument to GLSL compiler")
endif()
if(NOT EXISTS ${CMAKE_GLSL_COMPILER_INIT})
message(FATAL_ERROR "Could not find compiler set in environment variable GLSL_COMPILER:\n$ENV{GLSL_COMPILER}\n${CMAKE_GLSL_COMPILER_INIT}")
endif()
endif()
# Try finding it, or fall back to compilers named by CMAKE_GLSL_COMPILER_LIST
_cmake_find_compiler(GLSL)
else()
# Fall back to compilers named by CMAKE_GLSL_COMPILER_LIST
_cmake_find_compiler_path(GLSL)
endif()
mark_as_advanced(CMAKE_GLSL_COMPILER)
# configure variables set in this file for fast reload later on
configure_file(${CMAKE_CURRENT_LIST_DIR}/CMakeGLSLCompiler.cmake.in
${CMAKE_PLATFORM_INFO_DIR}/CMakeGLSLCompiler.cmake
@ONLY
)
set(CMAKE_GLSL_SOURCE_FILE_EXTENSIONS vert;frag;tese;tesc;geom;comp)
set(CMAKE_GLSL_COMPILER "@CMAKE_GLSL_COMPILER@")
set(CMAKE_GLSL_LINK_EXECUTABLE "echo")
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
set(CMAKE_GLSL_OUTPUT_EXTENSION .spv)
set(CMAKE_INCLUDE_FLAG_GLSL "-I")
set(CMAKE_GLSL_COMPILE_OBJECT "<CMAKE_GLSL_COMPILER> <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>")
set(CMAKE_GLSL_INFORMATION_LOADED 1)
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
if(CMAKE_GLSL_COMPILER_FORCED)
# The compiler configuration was forced by the user.
# Assume the user has configured all compiler information.
set(CMAKE_GLSL_COMPILER_WORKS TRUE)
return()
endif()
include(CMakeTestCompilerCommon)
# This file is used by EnableLanguage in cmGlobalGenerator to
# determine that that selected GLSL compiler can actually compile
# the most basic of programs. If not, a fatal error is set and
# cmake stops processing commands and will not generate any makefiles
# or projects.
if(NOT CMAKE_GLSL_COMPILER_WORKS)
PrintTestCompilerStatus("GLSL" "")
file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/main.vert
"#version 150\n"
"void main() {}\n")
# Need -c to just make a .spv file
try_compile(CMAKE_GLSL_COMPILER_WORKS ${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/main.vert
CMAKE_FLAGS -c
OUTPUT_VARIABLE __CMAKE_GLSL_COMPILER_OUTPUT)
# Move result from cache to normal variable.
set(CMAKE_GLSL_COMPILER_WORKS ${CMAKE_GLSL_COMPILER_WORKS})
unset(CMAKE_GLSL_COMPILER_WORKS CACHE)
set(GLSL_TEST_WAS_RUN 1)
endif()
if(NOT CMAKE_GLSL_COMPILER_WORKS)
PrintTestCompilerStatus("GLSL" " -- broken")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the GLSL compiler works failed with "
"the following output:\n${__CMAKE_GLSL_COMPILER_OUTPUT}\n\n")
message(FATAL_ERROR "The GLSL compiler \"${CMAKE_GLSL_COMPILER}\" "
"is not able to compile a simple test program.\nIt fails "
"with the following output:\n ${__CMAKE_GLSL_COMPILER_OUTPUT}\n\n"
"CMake will not be able to correctly generate this project.")
else()
if(GLSL_TEST_WAS_RUN)
PrintTestCompilerStatus("GLSL" " -- works")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the GLSL compiler works passed with "
"the following output:\n${__CMAKE_GLSL_COMPILER_OUTPUT}\n\n")
endif()
endif()
unset(__CMAKE_GLSL_COMPILER_OUTPUT)
......@@ -12,6 +12,7 @@
#include <mirrage/utils/messagebus.hpp>
#include <unordered_set>
#include <iostream>
namespace mirrage::gui {
......@@ -94,8 +95,7 @@ namespace mirrage::gui {
return false;
}
template <class Stream>
static Stream& print_names(Stream& stream)
static std::ostream& print_names(std::ostream& stream)
{
auto first = true;
for(auto dm : instances()) {
......
......@@ -26,7 +26,12 @@ namespace mirrage::gui {
void Debug_console_appender::write(const plog::Record& record)
{
auto msg = plog::TxtFormatter::format(record);
auto msg =
#ifdef _WIN32
plog::util::toNarrow(plog::TxtFormatter::format(record), 0);
#else
plog::TxtFormatter::format(record);
#endif
auto prev_pos = std::string::size_type(0);
auto pos = std::string::size_type(0);
while((pos = msg.find("\n", prev_pos)) != std::string::npos) {
......
......@@ -19,6 +19,7 @@ file(GLOB_RECURSE ALL_SHADERS
add_custom_target(mirrage_renderer_shaders SOURCES ${ALL_SHADERS})
set(MIRRAGE_GLSL_COMPILER "glslc" CACHE STRING "Path to glslc compiler")
foreach(GLSL ${GLSL_SOURCE_FILES})
get_filename_component(FILE_NAME ${GLSL} NAME)
......@@ -26,7 +27,7 @@ foreach(GLSL ${GLSL_SOURCE_FILES})
add_custom_command(
OUTPUT ${SPIRV}
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/shader/"
COMMAND ${CMAKE_GLSL_COMPILER} -o ${SPIRV} -c ${GLSL}
COMMAND ${MIRRAGE_GLSL_COMPILER} -o ${SPIRV} -c ${GLSL}
DEPENDS ${ALL_SHADERS})
list(APPEND SPIRV_BINARY_FILES ${SPIRV})
endforeach(GLSL)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment