Permalink
Browse files

build: fix the way lang_cfg.h is generated

This header is generated by running cmake/lang_cfg.cmake and
redirecting its stderr. If any warning is emitted by this script, it
ends up in the generated header and breaks the build.

To avoid such problems: pass the path to the header as an argument to
the cmake script and use the cmake 'file' command instead of 'message'.

We can't even use message(STATUS...) as - although it prints to stdout
as opposed to other types of messages - it prepends all output with
a double hyphen.
  • Loading branch information...
brgl committed Jun 21, 2017
1 parent e7e6210 commit cc3a9e611c15f32ae4913a87306699db60758245
Showing with 6 additions and 6 deletions.
  1. +5 −5 cmake/lang_cfg.cmake
  2. +1 −1 src/CMakeLists.txt
@@ -1,10 +1,10 @@
if(${CMAKE_ARGC} GREATER 1)
if ("${CMAKE_ARGV3}" STREQUAL "ENONLY")
message("#define ENGLISH_ONLY")
if(${CMAKE_ARGC} GREATER 2)
if ("${CMAKE_ARGV4}" STREQUAL "ENONLY")
file(APPEND ${CMAKE_ARGV3} " #define ENGLISH_ONLY")
else()
math(EXPR UPTO ${CMAKE_ARGC}-1)
foreach(i RANGE 3 ${UPTO})
message("#define LANG_${CMAKE_ARGV${i}}")
foreach(i RANGE 4 ${UPTO})
file(APPEND ${CMAKE_ARGV3} " #define LANG_${CMAKE_ARGV${i}}")
endforeach()
endif()
endif()
@@ -73,7 +73,7 @@ set_source_files_properties(${GENERATED_SRC}/ce_parse.h PROPERTIES GENERATED 1)
# lang_cfg.h
add_custom_command(
COMMENT "Generating ${GENERATED_SRC}/lang_cfg.h"
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_SOURCE_DIR}/cmake/lang_cfg.cmake ${LANG_CODES} 2> ${GENERATED_SRC}/lang_cfg.h
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_SOURCE_DIR}/cmake/lang_cfg.cmake ${GENERATED_SRC}/lang_cfg.h ${LANG_CODES}
DEPENDS ${LANGUAGE_FILES}
OUTPUT ${GENERATED_SRC}/lang_cfg.h
)

0 comments on commit cc3a9e6

Please sign in to comment.