Attached Files | flex-target-header-support.diff [^] (5,051 bytes) 2015-10-11 16:22 [Show Content] [Hide Content]From d301bbb5e9dc53e13e8367e58c953c3dd2245ec0 Mon Sep 17 00:00:00 2001
From: Chris Davies <chrislewellyn@googlemail.com>
Date: Sun, 11 Oct 2015 21:18:08 +0100
Subject: [PATCH] update the FLEX_TARGET macro to handle flex headers
---
Modules/FindFLEX.cmake | 83 ++++++++++++++++++++++++++++++++++----------------
1 file changed, 56 insertions(+), 27 deletions(-)
diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake
index c837c52..b1e85b6 100644
--- a/Modules/FindFLEX.cmake
+++ b/Modules/FindFLEX.cmake
@@ -27,13 +27,17 @@
#
# ::
#
-# FLEX_TARGET(Name FlexInput FlexOutput [COMPILE_FLAGS <string>])
+# FLEX_TARGET(Name FlexInput FlexOutput
+# [COMPILE_FLAGS <string>]
+# [DEFINES_FILE <string>]
+# )
#
# which creates a custom command to generate the <FlexOutput> file from
# the <FlexInput> file. If COMPILE_FLAGS option is specified, the next
-# parameter is added to the flex command line. Name is an alias used to
-# get details of this custom command. Indeed the macro defines the
-# following variables:
+# parameter is added to the flex command line. If flex is configured to
+# output a header file, the DEFINES_FILE option may be used to specify its
+# name. Name is an alias used to get details of this custom command.
+# Indeed the macro defines the following variables:
#
# ::
#
@@ -41,6 +45,7 @@
# FLEX_${Name}_OUTPUTS - the source file generated by the custom rule, an
# alias for FlexOutput
# FLEX_${Name}_INPUT - the flex source file, an alias for ${FlexInput}
+# FLEX_${Name}_OUTPUT_HEADER - the header flex output, if any.
#
#
#
@@ -145,31 +150,55 @@ if(FLEX_EXECUTABLE)
#============================================================
#
macro(FLEX_TARGET Name Input Output)
+ set(FLEX_TARGET_outputs "${Output}")
+ set(FLEX_EXECUTABLE_opts "")
+
+
+ set(FLEX_TARGET_PARAM_OPTIONS)
+ set(FLEX_TARGET_PARAM_ONE_VALUE_KEYWORDS
+ COMPILE_FLAGS
+ DEFINES_FILE
+ )
+ set(FLEX_TARGET_PARAM_MULTI_VALUE_KEYWORDS)
+
+ cmake_parse_arguments(
+ FLEX_TARGET_ARG
+ "${FLEX_TARGET_PARAM_OPTIONS}"
+ "${FLEX_TARGET_PARAM_ONE_VALUE_KEYWORDS}"
+ "${FLEX_TARGET_MULTI_VALUE_KEYWORDS}"
+ ${ARGN}
+ )
+
set(FLEX_TARGET_usage "FLEX_TARGET(<Name> <Input> <Output> [COMPILE_FLAGS <string>]")
- if(${ARGC} GREATER 3)
- if(${ARGC} EQUAL 5)
- if("${ARGV3}" STREQUAL "COMPILE_FLAGS")
- set(FLEX_EXECUTABLE_opts "${ARGV4}")
- separate_arguments(FLEX_EXECUTABLE_opts)
- else()
- message(SEND_ERROR ${FLEX_TARGET_usage})
- endif()
+
+ if(NOT "${FLEX_TARGET_ARG_UNPARSED_ARGUMENTS}" STREQUAL "")
+ message(SEND_ERROR ${FLEX_TARGET_usage})
+ else()
+ if(NOT "${FLEX_TARGET_ARG_COMPILE_FLAGS}" STREQUAL "")
+ set(FLEX_EXECUTABLE_opts "${FLEX_TARGET_ARG_COMPILE_FLAGS}")
+ separate_arguments(FLEX_EXECUTABLE_opts)
+ endif()
+ if(NOT "${FLEX_TARGET_ARG_DEFINES_FILE}" STREQUAL "")
+ list(APPEND FLEX_TARGET_outputs "${FLEX_TARGET_ARG_DEFINES_FILE}")
+ endif()
+
+ add_custom_command(OUTPUT ${FLEX_TARGET_outputs}
+ COMMAND ${FLEX_EXECUTABLE}
+ ARGS ${FLEX_EXECUTABLE_opts} -o${Output} ${Input}
+ DEPENDS ${Input}
+ COMMENT "[FLEX][${Name}] Building scanner with flex ${FLEX_VERSION}"
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+
+ set(FLEX_${Name}_DEFINED TRUE)
+ set(FLEX_${Name}_OUTPUTS ${Output})
+ set(FLEX_${Name}_INPUT ${Input})
+ set(FLEX_${Name}_COMPILE_FLAGS ${FLEX_EXECUTABLE_opts})
+ if("${FLEX_TARGET_ARG_DEFINES_FILE}" STREQUAL "")
+ set(FLEX_${Name}_OUTPUT_HEADER "")
else()
- message(SEND_ERROR ${FLEX_TARGET_usage})
+ set(FLEX_${Name}_OUTPUT_HEADER ${FLEX_TARGET_ARG_DEFINES_FILE})
endif()
endif()
-
- add_custom_command(OUTPUT ${Output}
- COMMAND ${FLEX_EXECUTABLE}
- ARGS ${FLEX_EXECUTABLE_opts} -o${Output} ${Input}
- DEPENDS ${Input}
- COMMENT "[FLEX][${Name}] Building scanner with flex ${FLEX_VERSION}"
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
-
- set(FLEX_${Name}_DEFINED TRUE)
- set(FLEX_${Name}_OUTPUTS ${Output})
- set(FLEX_${Name}_INPUT ${Input})
- set(FLEX_${Name}_COMPILE_FLAGS ${FLEX_EXECUTABLE_opts})
endmacro()
#============================================================
@@ -181,11 +210,11 @@ if(FLEX_EXECUTABLE)
macro(ADD_FLEX_BISON_DEPENDENCY FlexTarget BisonTarget)
if(NOT FLEX_${FlexTarget}_OUTPUTS)
- message(SEND_ERROR "Flex target `${FlexTarget}' does not exists.")
+ message(SEND_ERROR "Flex target `${FlexTarget}' does not exist.")
endif()
if(NOT BISON_${BisonTarget}_OUTPUT_HEADER)
- message(SEND_ERROR "Bison target `${BisonTarget}' does not exists.")
+ message(SEND_ERROR "Bison target `${BisonTarget}' does not exist.")
endif()
set_source_files_properties(${FLEX_${FlexTarget}_OUTPUTS}
--
1.9.4.msysgit.0
flex-target-header-support-v2.diff [^] (5,934 bytes) 2015-10-11 16:43 [Show Content] [Hide Content]From d301bbb5e9dc53e13e8367e58c953c3dd2245ec0 Mon Sep 17 00:00:00 2001
From: Chris Davies <chrislewellyn@googlemail.com>
Date: Sun, 11 Oct 2015 21:18:08 +0100
Subject: [PATCH 1/2] update the FLEX_TARGET macro to handle flex headers
---
Modules/FindFLEX.cmake | 83 ++++++++++++++++++++++++++++++++++----------------
1 file changed, 56 insertions(+), 27 deletions(-)
diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake
index c837c52..b1e85b6 100644
--- a/Modules/FindFLEX.cmake
+++ b/Modules/FindFLEX.cmake
@@ -27,13 +27,17 @@
#
# ::
#
-# FLEX_TARGET(Name FlexInput FlexOutput [COMPILE_FLAGS <string>])
+# FLEX_TARGET(Name FlexInput FlexOutput
+# [COMPILE_FLAGS <string>]
+# [DEFINES_FILE <string>]
+# )
#
# which creates a custom command to generate the <FlexOutput> file from
# the <FlexInput> file. If COMPILE_FLAGS option is specified, the next
-# parameter is added to the flex command line. Name is an alias used to
-# get details of this custom command. Indeed the macro defines the
-# following variables:
+# parameter is added to the flex command line. If flex is configured to
+# output a header file, the DEFINES_FILE option may be used to specify its
+# name. Name is an alias used to get details of this custom command.
+# Indeed the macro defines the following variables:
#
# ::
#
@@ -41,6 +45,7 @@
# FLEX_${Name}_OUTPUTS - the source file generated by the custom rule, an
# alias for FlexOutput
# FLEX_${Name}_INPUT - the flex source file, an alias for ${FlexInput}
+# FLEX_${Name}_OUTPUT_HEADER - the header flex output, if any.
#
#
#
@@ -145,31 +150,55 @@ if(FLEX_EXECUTABLE)
#============================================================
#
macro(FLEX_TARGET Name Input Output)
+ set(FLEX_TARGET_outputs "${Output}")
+ set(FLEX_EXECUTABLE_opts "")
+
+
+ set(FLEX_TARGET_PARAM_OPTIONS)
+ set(FLEX_TARGET_PARAM_ONE_VALUE_KEYWORDS
+ COMPILE_FLAGS
+ DEFINES_FILE
+ )
+ set(FLEX_TARGET_PARAM_MULTI_VALUE_KEYWORDS)
+
+ cmake_parse_arguments(
+ FLEX_TARGET_ARG
+ "${FLEX_TARGET_PARAM_OPTIONS}"
+ "${FLEX_TARGET_PARAM_ONE_VALUE_KEYWORDS}"
+ "${FLEX_TARGET_MULTI_VALUE_KEYWORDS}"
+ ${ARGN}
+ )
+
set(FLEX_TARGET_usage "FLEX_TARGET(<Name> <Input> <Output> [COMPILE_FLAGS <string>]")
- if(${ARGC} GREATER 3)
- if(${ARGC} EQUAL 5)
- if("${ARGV3}" STREQUAL "COMPILE_FLAGS")
- set(FLEX_EXECUTABLE_opts "${ARGV4}")
- separate_arguments(FLEX_EXECUTABLE_opts)
- else()
- message(SEND_ERROR ${FLEX_TARGET_usage})
- endif()
+
+ if(NOT "${FLEX_TARGET_ARG_UNPARSED_ARGUMENTS}" STREQUAL "")
+ message(SEND_ERROR ${FLEX_TARGET_usage})
+ else()
+ if(NOT "${FLEX_TARGET_ARG_COMPILE_FLAGS}" STREQUAL "")
+ set(FLEX_EXECUTABLE_opts "${FLEX_TARGET_ARG_COMPILE_FLAGS}")
+ separate_arguments(FLEX_EXECUTABLE_opts)
+ endif()
+ if(NOT "${FLEX_TARGET_ARG_DEFINES_FILE}" STREQUAL "")
+ list(APPEND FLEX_TARGET_outputs "${FLEX_TARGET_ARG_DEFINES_FILE}")
+ endif()
+
+ add_custom_command(OUTPUT ${FLEX_TARGET_outputs}
+ COMMAND ${FLEX_EXECUTABLE}
+ ARGS ${FLEX_EXECUTABLE_opts} -o${Output} ${Input}
+ DEPENDS ${Input}
+ COMMENT "[FLEX][${Name}] Building scanner with flex ${FLEX_VERSION}"
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+
+ set(FLEX_${Name}_DEFINED TRUE)
+ set(FLEX_${Name}_OUTPUTS ${Output})
+ set(FLEX_${Name}_INPUT ${Input})
+ set(FLEX_${Name}_COMPILE_FLAGS ${FLEX_EXECUTABLE_opts})
+ if("${FLEX_TARGET_ARG_DEFINES_FILE}" STREQUAL "")
+ set(FLEX_${Name}_OUTPUT_HEADER "")
else()
- message(SEND_ERROR ${FLEX_TARGET_usage})
+ set(FLEX_${Name}_OUTPUT_HEADER ${FLEX_TARGET_ARG_DEFINES_FILE})
endif()
endif()
-
- add_custom_command(OUTPUT ${Output}
- COMMAND ${FLEX_EXECUTABLE}
- ARGS ${FLEX_EXECUTABLE_opts} -o${Output} ${Input}
- DEPENDS ${Input}
- COMMENT "[FLEX][${Name}] Building scanner with flex ${FLEX_VERSION}"
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
-
- set(FLEX_${Name}_DEFINED TRUE)
- set(FLEX_${Name}_OUTPUTS ${Output})
- set(FLEX_${Name}_INPUT ${Input})
- set(FLEX_${Name}_COMPILE_FLAGS ${FLEX_EXECUTABLE_opts})
endmacro()
#============================================================
@@ -181,11 +210,11 @@ if(FLEX_EXECUTABLE)
macro(ADD_FLEX_BISON_DEPENDENCY FlexTarget BisonTarget)
if(NOT FLEX_${FlexTarget}_OUTPUTS)
- message(SEND_ERROR "Flex target `${FlexTarget}' does not exists.")
+ message(SEND_ERROR "Flex target `${FlexTarget}' does not exist.")
endif()
if(NOT BISON_${BisonTarget}_OUTPUT_HEADER)
- message(SEND_ERROR "Bison target `${BisonTarget}' does not exists.")
+ message(SEND_ERROR "Bison target `${BisonTarget}' does not exist.")
endif()
set_source_files_properties(${FLEX_${FlexTarget}_OUTPUTS}
--
1.9.4.msysgit.0
From b1b5265e45caaa92af6c69143a3d58dd3ff3d674 Mon Sep 17 00:00:00 2001
From: Chris Davies <chrislewellyn@googlemail.com>
Date: Sun, 11 Oct 2015 21:41:27 +0100
Subject: [PATCH 2/2] ... and I forgot to update the macro usage. Sigh
---
Modules/FindFLEX.cmake | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake
index b1e85b6..96bbba1 100644
--- a/Modules/FindFLEX.cmake
+++ b/Modules/FindFLEX.cmake
@@ -169,7 +169,7 @@ if(FLEX_EXECUTABLE)
${ARGN}
)
- set(FLEX_TARGET_usage "FLEX_TARGET(<Name> <Input> <Output> [COMPILE_FLAGS <string>]")
+ set(FLEX_TARGET_usage "FLEX_TARGET(<Name> <Input> <Output> [COMPILE_FLAGS <string>] [DEFINES_FILE <string>]")
if(NOT "${FLEX_TARGET_ARG_UNPARSED_ARGUMENTS}" STREQUAL "")
message(SEND_ERROR ${FLEX_TARGET_usage})
--
1.9.4.msysgit.0
flex-target-header-support-v3.diff [^] (7,506 bytes) 2015-10-17 12:37 [Show Content] [Hide Content]From ee687333a03c186414f2cb6fe3e868cab37f395d Mon Sep 17 00:00:00 2001
From: Chris Davies <chrislewellyn@googlemail.com>
Date: Sat, 17 Oct 2015 17:29:57 +0100
Subject: [PATCH 1/2] [0015781] Convert FindFlex macro to use
CMAKE_PARSE_ARGUMENTS
---
Modules/FindFLEX.cmake | 59 +++++++++++++++++++++++++++++++-------------------
1 file changed, 37 insertions(+), 22 deletions(-)
diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake
index c837c52..5582be1 100644
--- a/Modules/FindFLEX.cmake
+++ b/Modules/FindFLEX.cmake
@@ -113,6 +113,8 @@ find_path(FLEX_INCLUDE_DIR FlexLexer.h
mark_as_advanced(FL_LIBRARY FLEX_INCLUDE_DIR)
+include(CMakeParseArguments)
+
set(FLEX_INCLUDE_DIRS ${FLEX_INCLUDE_DIR})
set(FLEX_LIBRARIES ${FL_LIBRARY})
@@ -145,31 +147,44 @@ if(FLEX_EXECUTABLE)
#============================================================
#
macro(FLEX_TARGET Name Input Output)
+ set(FLEX_EXECUTABLE_opts "")
+
+ set(FLEX_TARGET_PARAM_OPTIONS)
+ set(FLEX_TARGET_PARAM_ONE_VALUE_KEYWORDS
+ COMPILE_FLAGS
+ )
+ set(FLEX_TARGET_PARAM_MULTI_VALUE_KEYWORDS)
+
+ cmake_parse_arguments(
+ FLEX_TARGET_ARG
+ "${FLEX_TARGET_PARAM_OPTIONS}"
+ "${FLEX_TARGET_PARAM_ONE_VALUE_KEYWORDS}"
+ "${FLEX_TARGET_MULTI_VALUE_KEYWORDS}"
+ ${ARGN}
+ )
+
set(FLEX_TARGET_usage "FLEX_TARGET(<Name> <Input> <Output> [COMPILE_FLAGS <string>]")
- if(${ARGC} GREATER 3)
- if(${ARGC} EQUAL 5)
- if("${ARGV3}" STREQUAL "COMPILE_FLAGS")
- set(FLEX_EXECUTABLE_opts "${ARGV4}")
- separate_arguments(FLEX_EXECUTABLE_opts)
- else()
- message(SEND_ERROR ${FLEX_TARGET_usage})
- endif()
- else()
- message(SEND_ERROR ${FLEX_TARGET_usage})
+
+ if(NOT "${FLEX_TARGET_ARG_UNPARSED_ARGUMENTS}" STREQUAL "")
+ message(SEND_ERROR ${FLEX_TARGET_usage})
+ else()
+ if(NOT "${FLEX_TARGET_ARG_COMPILE_FLAGS}" STREQUAL "")
+ set(FLEX_EXECUTABLE_opts "${FLEX_TARGET_ARG_COMPILE_FLAGS}")
+ separate_arguments(FLEX_EXECUTABLE_opts)
endif()
- endif()
- add_custom_command(OUTPUT ${Output}
- COMMAND ${FLEX_EXECUTABLE}
- ARGS ${FLEX_EXECUTABLE_opts} -o${Output} ${Input}
- DEPENDS ${Input}
- COMMENT "[FLEX][${Name}] Building scanner with flex ${FLEX_VERSION}"
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
-
- set(FLEX_${Name}_DEFINED TRUE)
- set(FLEX_${Name}_OUTPUTS ${Output})
- set(FLEX_${Name}_INPUT ${Input})
- set(FLEX_${Name}_COMPILE_FLAGS ${FLEX_EXECUTABLE_opts})
+ add_custom_command(OUTPUT ${Output}
+ COMMAND ${FLEX_EXECUTABLE}
+ ARGS ${FLEX_EXECUTABLE_opts} -o${Output} ${Input}
+ DEPENDS ${Input}
+ COMMENT "[FLEX][${Name}] Building scanner with flex ${FLEX_VERSION}"
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+
+ set(FLEX_${Name}_DEFINED TRUE)
+ set(FLEX_${Name}_OUTPUTS ${Output})
+ set(FLEX_${Name}_INPUT ${Input})
+ set(FLEX_${Name}_COMPILE_FLAGS ${FLEX_EXECUTABLE_opts})
+ endif()
endmacro()
#============================================================
--
1.9.4.msysgit.0
From 392ce37bb789f3830eefdbf0ea650de53c8b350a Mon Sep 17 00:00:00 2001
From: Chris Davies <chrislewellyn@googlemail.com>
Date: Sat, 17 Oct 2015 17:33:47 +0100
Subject: [PATCH 2/2] [0015781] FindFlex macro now supports flex headers with
DEFINES_FILES option
---
Modules/FindFLEX.cmake | 37 +++++++++++++++++++++++++------------
1 file changed, 25 insertions(+), 12 deletions(-)
diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake
index 5582be1..6a5691f 100644
--- a/Modules/FindFLEX.cmake
+++ b/Modules/FindFLEX.cmake
@@ -27,13 +27,17 @@
#
# ::
#
-# FLEX_TARGET(Name FlexInput FlexOutput [COMPILE_FLAGS <string>])
+# FLEX_TARGET(Name FlexInput FlexOutput
+# [COMPILE_FLAGS <string>]
+# [DEFINES_FILE <string>]
+# )
#
# which creates a custom command to generate the <FlexOutput> file from
# the <FlexInput> file. If COMPILE_FLAGS option is specified, the next
-# parameter is added to the flex command line. Name is an alias used to
-# get details of this custom command. Indeed the macro defines the
-# following variables:
+# parameter is added to the flex command line. If flex is configured to
+# output a header file, the DEFINES_FILE option may be used to specify its
+# name. Name is an alias used to get details of this custom command.
+# Indeed the macro defines the following variables:
#
# ::
#
@@ -41,6 +45,7 @@
# FLEX_${Name}_OUTPUTS - the source file generated by the custom rule, an
# alias for FlexOutput
# FLEX_${Name}_INPUT - the flex source file, an alias for ${FlexInput}
+# FLEX_${Name}_OUTPUT_HEADER - the header flex output, if any.
#
#
#
@@ -113,8 +118,6 @@ find_path(FLEX_INCLUDE_DIR FlexLexer.h
mark_as_advanced(FL_LIBRARY FLEX_INCLUDE_DIR)
-include(CMakeParseArguments)
-
set(FLEX_INCLUDE_DIRS ${FLEX_INCLUDE_DIR})
set(FLEX_LIBRARIES ${FL_LIBRARY})
@@ -147,11 +150,13 @@ if(FLEX_EXECUTABLE)
#============================================================
#
macro(FLEX_TARGET Name Input Output)
+ set(FLEX_TARGET_outputs "${Output}")
set(FLEX_EXECUTABLE_opts "")
-
+
set(FLEX_TARGET_PARAM_OPTIONS)
set(FLEX_TARGET_PARAM_ONE_VALUE_KEYWORDS
COMPILE_FLAGS
+ DEFINES_FILE
)
set(FLEX_TARGET_PARAM_MULTI_VALUE_KEYWORDS)
@@ -163,7 +168,7 @@ if(FLEX_EXECUTABLE)
${ARGN}
)
- set(FLEX_TARGET_usage "FLEX_TARGET(<Name> <Input> <Output> [COMPILE_FLAGS <string>]")
+ set(FLEX_TARGET_usage "FLEX_TARGET(<Name> <Input> <Output> [COMPILE_FLAGS <string>] [DEFINES_FILE <string>]")
if(NOT "${FLEX_TARGET_ARG_UNPARSED_ARGUMENTS}" STREQUAL "")
message(SEND_ERROR ${FLEX_TARGET_usage})
@@ -172,8 +177,11 @@ if(FLEX_EXECUTABLE)
set(FLEX_EXECUTABLE_opts "${FLEX_TARGET_ARG_COMPILE_FLAGS}")
separate_arguments(FLEX_EXECUTABLE_opts)
endif()
-
- add_custom_command(OUTPUT ${Output}
+ if(NOT "${FLEX_TARGET_ARG_DEFINES_FILE}" STREQUAL "")
+ list(APPEND FLEX_TARGET_outputs "${FLEX_TARGET_ARG_DEFINES_FILE}")
+ endif()
+
+ add_custom_command(OUTPUT ${FLEX_TARGET_outputs}
COMMAND ${FLEX_EXECUTABLE}
ARGS ${FLEX_EXECUTABLE_opts} -o${Output} ${Input}
DEPENDS ${Input}
@@ -184,6 +192,11 @@ if(FLEX_EXECUTABLE)
set(FLEX_${Name}_OUTPUTS ${Output})
set(FLEX_${Name}_INPUT ${Input})
set(FLEX_${Name}_COMPILE_FLAGS ${FLEX_EXECUTABLE_opts})
+ if("${FLEX_TARGET_ARG_DEFINES_FILE}" STREQUAL "")
+ set(FLEX_${Name}_OUTPUT_HEADER "")
+ else()
+ set(FLEX_${Name}_OUTPUT_HEADER ${FLEX_TARGET_ARG_DEFINES_FILE})
+ endif()
endif()
endmacro()
#============================================================
@@ -196,11 +209,11 @@ if(FLEX_EXECUTABLE)
macro(ADD_FLEX_BISON_DEPENDENCY FlexTarget BisonTarget)
if(NOT FLEX_${FlexTarget}_OUTPUTS)
- message(SEND_ERROR "Flex target `${FlexTarget}' does not exists.")
+ message(SEND_ERROR "Flex target `${FlexTarget}' does not exist.")
endif()
if(NOT BISON_${BisonTarget}_OUTPUT_HEADER)
- message(SEND_ERROR "Bison target `${BisonTarget}' does not exists.")
+ message(SEND_ERROR "Bison target `${BisonTarget}' does not exist.")
endif()
set_source_files_properties(${FLEX_${FlexTarget}_OUTPUTS}
--
1.9.4.msysgit.0
flex-target-header-support-v4.diff [^] (7,281 bytes) 2015-10-17 12:55 [Show Content] [Hide Content]From 84da894c632445ff084211a80a62b1eed57fe719 Mon Sep 17 00:00:00 2001
From: Chris Davies <chrislewellyn@googlemail.com>
Date: Sat, 17 Oct 2015 17:50:00 +0100
Subject: [PATCH 1/2] [0015781] Convert FindFlex macro to use
CMAKE_PARSE_ARGUMENTS
---
Modules/FindFLEX.cmake | 59 +++++++++++++++++++++++++++++++-------------------
1 file changed, 37 insertions(+), 22 deletions(-)
diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake
index c837c52..5582be1 100644
--- a/Modules/FindFLEX.cmake
+++ b/Modules/FindFLEX.cmake
@@ -113,6 +113,8 @@ find_path(FLEX_INCLUDE_DIR FlexLexer.h
mark_as_advanced(FL_LIBRARY FLEX_INCLUDE_DIR)
+include(CMakeParseArguments)
+
set(FLEX_INCLUDE_DIRS ${FLEX_INCLUDE_DIR})
set(FLEX_LIBRARIES ${FL_LIBRARY})
@@ -145,31 +147,44 @@ if(FLEX_EXECUTABLE)
#============================================================
#
macro(FLEX_TARGET Name Input Output)
+ set(FLEX_EXECUTABLE_opts "")
+
+ set(FLEX_TARGET_PARAM_OPTIONS)
+ set(FLEX_TARGET_PARAM_ONE_VALUE_KEYWORDS
+ COMPILE_FLAGS
+ )
+ set(FLEX_TARGET_PARAM_MULTI_VALUE_KEYWORDS)
+
+ cmake_parse_arguments(
+ FLEX_TARGET_ARG
+ "${FLEX_TARGET_PARAM_OPTIONS}"
+ "${FLEX_TARGET_PARAM_ONE_VALUE_KEYWORDS}"
+ "${FLEX_TARGET_MULTI_VALUE_KEYWORDS}"
+ ${ARGN}
+ )
+
set(FLEX_TARGET_usage "FLEX_TARGET(<Name> <Input> <Output> [COMPILE_FLAGS <string>]")
- if(${ARGC} GREATER 3)
- if(${ARGC} EQUAL 5)
- if("${ARGV3}" STREQUAL "COMPILE_FLAGS")
- set(FLEX_EXECUTABLE_opts "${ARGV4}")
- separate_arguments(FLEX_EXECUTABLE_opts)
- else()
- message(SEND_ERROR ${FLEX_TARGET_usage})
- endif()
- else()
- message(SEND_ERROR ${FLEX_TARGET_usage})
+
+ if(NOT "${FLEX_TARGET_ARG_UNPARSED_ARGUMENTS}" STREQUAL "")
+ message(SEND_ERROR ${FLEX_TARGET_usage})
+ else()
+ if(NOT "${FLEX_TARGET_ARG_COMPILE_FLAGS}" STREQUAL "")
+ set(FLEX_EXECUTABLE_opts "${FLEX_TARGET_ARG_COMPILE_FLAGS}")
+ separate_arguments(FLEX_EXECUTABLE_opts)
endif()
- endif()
- add_custom_command(OUTPUT ${Output}
- COMMAND ${FLEX_EXECUTABLE}
- ARGS ${FLEX_EXECUTABLE_opts} -o${Output} ${Input}
- DEPENDS ${Input}
- COMMENT "[FLEX][${Name}] Building scanner with flex ${FLEX_VERSION}"
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
-
- set(FLEX_${Name}_DEFINED TRUE)
- set(FLEX_${Name}_OUTPUTS ${Output})
- set(FLEX_${Name}_INPUT ${Input})
- set(FLEX_${Name}_COMPILE_FLAGS ${FLEX_EXECUTABLE_opts})
+ add_custom_command(OUTPUT ${Output}
+ COMMAND ${FLEX_EXECUTABLE}
+ ARGS ${FLEX_EXECUTABLE_opts} -o${Output} ${Input}
+ DEPENDS ${Input}
+ COMMENT "[FLEX][${Name}] Building scanner with flex ${FLEX_VERSION}"
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+
+ set(FLEX_${Name}_DEFINED TRUE)
+ set(FLEX_${Name}_OUTPUTS ${Output})
+ set(FLEX_${Name}_INPUT ${Input})
+ set(FLEX_${Name}_COMPILE_FLAGS ${FLEX_EXECUTABLE_opts})
+ endif()
endmacro()
#============================================================
--
1.9.4.msysgit.0
From 3ff33eaeddcd5e8b86ab017e3169ba47186d7a5e Mon Sep 17 00:00:00 2001
From: Chris Davies <chrislewellyn@googlemail.com>
Date: Sat, 17 Oct 2015 17:51:51 +0100
Subject: [PATCH 2/2] [0015781] FindFlex macro now supports flex headers with
DEFINES_FILES option
---
Modules/FindFLEX.cmake | 35 +++++++++++++++++++++++++----------
1 file changed, 25 insertions(+), 10 deletions(-)
diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake
index 5582be1..a4211e5 100644
--- a/Modules/FindFLEX.cmake
+++ b/Modules/FindFLEX.cmake
@@ -27,13 +27,17 @@
#
# ::
#
-# FLEX_TARGET(Name FlexInput FlexOutput [COMPILE_FLAGS <string>])
+# FLEX_TARGET(Name FlexInput FlexOutput
+# [COMPILE_FLAGS <string>]
+# [DEFINES_FILE <string>]
+# )
#
# which creates a custom command to generate the <FlexOutput> file from
# the <FlexInput> file. If COMPILE_FLAGS option is specified, the next
-# parameter is added to the flex command line. Name is an alias used to
-# get details of this custom command. Indeed the macro defines the
-# following variables:
+# parameter is added to the flex command line. If flex is configured to
+# output a header file, the DEFINES_FILE option may be used to specify its
+# name. Name is an alias used to get details of this custom command.
+# Indeed the macro defines the following variables:
#
# ::
#
@@ -41,6 +45,7 @@
# FLEX_${Name}_OUTPUTS - the source file generated by the custom rule, an
# alias for FlexOutput
# FLEX_${Name}_INPUT - the flex source file, an alias for ${FlexInput}
+# FLEX_${Name}_OUTPUT_HEADER - the header flex output, if any.
#
#
#
@@ -147,11 +152,13 @@ if(FLEX_EXECUTABLE)
#============================================================
#
macro(FLEX_TARGET Name Input Output)
+ set(FLEX_TARGET_outputs "${Output}")
set(FLEX_EXECUTABLE_opts "")
-
+
set(FLEX_TARGET_PARAM_OPTIONS)
set(FLEX_TARGET_PARAM_ONE_VALUE_KEYWORDS
COMPILE_FLAGS
+ DEFINES_FILE
)
set(FLEX_TARGET_PARAM_MULTI_VALUE_KEYWORDS)
@@ -163,7 +170,7 @@ if(FLEX_EXECUTABLE)
${ARGN}
)
- set(FLEX_TARGET_usage "FLEX_TARGET(<Name> <Input> <Output> [COMPILE_FLAGS <string>]")
+ set(FLEX_TARGET_usage "FLEX_TARGET(<Name> <Input> <Output> [COMPILE_FLAGS <string>] [DEFINES_FILE <string>]")
if(NOT "${FLEX_TARGET_ARG_UNPARSED_ARGUMENTS}" STREQUAL "")
message(SEND_ERROR ${FLEX_TARGET_usage})
@@ -172,8 +179,11 @@ if(FLEX_EXECUTABLE)
set(FLEX_EXECUTABLE_opts "${FLEX_TARGET_ARG_COMPILE_FLAGS}")
separate_arguments(FLEX_EXECUTABLE_opts)
endif()
-
- add_custom_command(OUTPUT ${Output}
+ if(NOT "${FLEX_TARGET_ARG_DEFINES_FILE}" STREQUAL "")
+ list(APPEND FLEX_TARGET_outputs "${FLEX_TARGET_ARG_DEFINES_FILE}")
+ endif()
+
+ add_custom_command(OUTPUT ${FLEX_TARGET_outputs}
COMMAND ${FLEX_EXECUTABLE}
ARGS ${FLEX_EXECUTABLE_opts} -o${Output} ${Input}
DEPENDS ${Input}
@@ -184,6 +194,11 @@ if(FLEX_EXECUTABLE)
set(FLEX_${Name}_OUTPUTS ${Output})
set(FLEX_${Name}_INPUT ${Input})
set(FLEX_${Name}_COMPILE_FLAGS ${FLEX_EXECUTABLE_opts})
+ if("${FLEX_TARGET_ARG_DEFINES_FILE}" STREQUAL "")
+ set(FLEX_${Name}_OUTPUT_HEADER "")
+ else()
+ set(FLEX_${Name}_OUTPUT_HEADER ${FLEX_TARGET_ARG_DEFINES_FILE})
+ endif()
endif()
endmacro()
#============================================================
@@ -196,11 +211,11 @@ if(FLEX_EXECUTABLE)
macro(ADD_FLEX_BISON_DEPENDENCY FlexTarget BisonTarget)
if(NOT FLEX_${FlexTarget}_OUTPUTS)
- message(SEND_ERROR "Flex target `${FlexTarget}' does not exists.")
+ message(SEND_ERROR "Flex target `${FlexTarget}' does not exist.")
endif()
if(NOT BISON_${BisonTarget}_OUTPUT_HEADER)
- message(SEND_ERROR "Bison target `${BisonTarget}' does not exists.")
+ message(SEND_ERROR "Bison target `${BisonTarget}' does not exist.")
endif()
set_source_files_properties(${FLEX_${FlexTarget}_OUTPUTS}
--
1.9.4.msysgit.0
flex-target-header-support-v5.diff [^] (7,323 bytes) 2015-10-19 13:00 [Show Content] [Hide Content]From dcfcc8375c122a33ec52dc9ccd0e9e1321ae6ba4 Mon Sep 17 00:00:00 2001
From: Chris Davies <chrislewellyn@googlemail.com>
Date: Mon, 19 Oct 2015 17:55:17 +0100
Subject: [PATCH 1/2] [0015781] Convert FindFlex macro to use
CMAKE_PARSE_ARGUMENTS
---
Modules/FindFLEX.cmake | 59 +++++++++++++++++++++++++++++++-------------------
1 file changed, 37 insertions(+), 22 deletions(-)
diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake
index c837c52..b02f036 100644
--- a/Modules/FindFLEX.cmake
+++ b/Modules/FindFLEX.cmake
@@ -113,6 +113,8 @@ find_path(FLEX_INCLUDE_DIR FlexLexer.h
mark_as_advanced(FL_LIBRARY FLEX_INCLUDE_DIR)
+include(CMakeParseArguments)
+
set(FLEX_INCLUDE_DIRS ${FLEX_INCLUDE_DIR})
set(FLEX_LIBRARIES ${FL_LIBRARY})
@@ -145,31 +147,44 @@ if(FLEX_EXECUTABLE)
#============================================================
#
macro(FLEX_TARGET Name Input Output)
+ set(FLEX_EXECUTABLE_opts "")
+
+ set(FLEX_TARGET_PARAM_OPTIONS)
+ set(FLEX_TARGET_PARAM_ONE_VALUE_KEYWORDS
+ COMPILE_FLAGS
+ )
+ set(FLEX_TARGET_PARAM_MULTI_VALUE_KEYWORDS)
+
+ cmake_parse_arguments(
+ FLEX_TARGET_ARG
+ "${FLEX_TARGET_PARAM_OPTIONS}"
+ "${FLEX_TARGET_PARAM_ONE_VALUE_KEYWORDS}"
+ "${FLEX_TARGET_MULTI_VALUE_KEYWORDS}"
+ ${ARGN}
+ )
+
set(FLEX_TARGET_usage "FLEX_TARGET(<Name> <Input> <Output> [COMPILE_FLAGS <string>]")
- if(${ARGC} GREATER 3)
- if(${ARGC} EQUAL 5)
- if("${ARGV3}" STREQUAL "COMPILE_FLAGS")
- set(FLEX_EXECUTABLE_opts "${ARGV4}")
- separate_arguments(FLEX_EXECUTABLE_opts)
- else()
- message(SEND_ERROR ${FLEX_TARGET_usage})
- endif()
- else()
- message(SEND_ERROR ${FLEX_TARGET_usage})
+
+ if(NOT "${FLEX_TARGET_ARG_UNPARSED_ARGUMENTS}" STREQUAL "")
+ message(SEND_ERROR ${FLEX_TARGET_usage})
+ else()
+ if(NOT "${FLEX_TARGET_ARG_COMPILE_FLAGS}" STREQUAL "")
+ set(FLEX_EXECUTABLE_opts "${FLEX_TARGET_ARG_COMPILE_FLAGS}")
+ separate_arguments(FLEX_EXECUTABLE_opts)
endif()
- endif()
- add_custom_command(OUTPUT ${Output}
- COMMAND ${FLEX_EXECUTABLE}
- ARGS ${FLEX_EXECUTABLE_opts} -o${Output} ${Input}
- DEPENDS ${Input}
- COMMENT "[FLEX][${Name}] Building scanner with flex ${FLEX_VERSION}"
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
-
- set(FLEX_${Name}_DEFINED TRUE)
- set(FLEX_${Name}_OUTPUTS ${Output})
- set(FLEX_${Name}_INPUT ${Input})
- set(FLEX_${Name}_COMPILE_FLAGS ${FLEX_EXECUTABLE_opts})
+ add_custom_command(OUTPUT ${Output}
+ COMMAND ${FLEX_EXECUTABLE}
+ ARGS ${FLEX_EXECUTABLE_opts} -o${Output} ${Input}
+ DEPENDS ${Input}
+ COMMENT "[FLEX][${Name}] Building scanner with flex ${FLEX_VERSION}"
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+
+ set(FLEX_${Name}_DEFINED TRUE)
+ set(FLEX_${Name}_OUTPUTS ${Output})
+ set(FLEX_${Name}_INPUT ${Input})
+ set(FLEX_${Name}_COMPILE_FLAGS ${FLEX_EXECUTABLE_opts})
+ endif()
endmacro()
#============================================================
--
1.9.4.msysgit.0
From a62f54d2aea7d83a218f65b635d8d972d7e032ce Mon Sep 17 00:00:00 2001
From: Chris Davies <chrislewellyn@googlemail.com>
Date: Mon, 19 Oct 2015 17:58:10 +0100
Subject: [PATCH 2/2] [0015781] FindFlex macro now supports flex headers with
DEFINES_FILE option
---
Modules/FindFLEX.cmake | 32 ++++++++++++++++++++++++--------
1 file changed, 24 insertions(+), 8 deletions(-)
diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake
index b02f036..e41ecb4 100644
--- a/Modules/FindFLEX.cmake
+++ b/Modules/FindFLEX.cmake
@@ -27,13 +27,17 @@
#
# ::
#
-# FLEX_TARGET(Name FlexInput FlexOutput [COMPILE_FLAGS <string>])
+# FLEX_TARGET(Name FlexInput FlexOutput
+# [COMPILE_FLAGS <string>]
+# [DEFINES_FILE <string>]
+# )
#
# which creates a custom command to generate the <FlexOutput> file from
# the <FlexInput> file. If COMPILE_FLAGS option is specified, the next
-# parameter is added to the flex command line. Name is an alias used to
-# get details of this custom command. Indeed the macro defines the
-# following variables:
+# parameter is added to the flex command line. If flex is configured to
+# output a header file, the DEFINES_FILE option may be used to specify its
+# name. Name is an alias used to get details of this custom command.
+# Indeed the macro defines the following variables:
#
# ::
#
@@ -41,6 +45,7 @@
# FLEX_${Name}_OUTPUTS - the source file generated by the custom rule, an
# alias for FlexOutput
# FLEX_${Name}_INPUT - the flex source file, an alias for ${FlexInput}
+# FLEX_${Name}_OUTPUT_HEADER - the header flex output, if any.
#
#
#
@@ -147,11 +152,13 @@ if(FLEX_EXECUTABLE)
#============================================================
#
macro(FLEX_TARGET Name Input Output)
+ set(FLEX_TARGET_outputs "${Output}")
set(FLEX_EXECUTABLE_opts "")
set(FLEX_TARGET_PARAM_OPTIONS)
set(FLEX_TARGET_PARAM_ONE_VALUE_KEYWORDS
COMPILE_FLAGS
+ DEFINES_FILE
)
set(FLEX_TARGET_PARAM_MULTI_VALUE_KEYWORDS)
@@ -163,7 +170,7 @@ if(FLEX_EXECUTABLE)
${ARGN}
)
- set(FLEX_TARGET_usage "FLEX_TARGET(<Name> <Input> <Output> [COMPILE_FLAGS <string>]")
+ set(FLEX_TARGET_usage "FLEX_TARGET(<Name> <Input> <Output> [COMPILE_FLAGS <string>] [DEFINES_FILE <string>]")
if(NOT "${FLEX_TARGET_ARG_UNPARSED_ARGUMENTS}" STREQUAL "")
message(SEND_ERROR ${FLEX_TARGET_usage})
@@ -172,8 +179,12 @@ if(FLEX_EXECUTABLE)
set(FLEX_EXECUTABLE_opts "${FLEX_TARGET_ARG_COMPILE_FLAGS}")
separate_arguments(FLEX_EXECUTABLE_opts)
endif()
+ if(NOT "${FLEX_TARGET_ARG_DEFINES_FILE}" STREQUAL "")
+ list(APPEND FLEX_TARGET_outputs "${FLEX_TARGET_ARG_DEFINES_FILE}")
+ list(APPEND FLEX_EXECUTABLE_opts --header-file=${FLEX_TARGET_ARG_DEFINES_FILE})
+ endif()
- add_custom_command(OUTPUT ${Output}
+ add_custom_command(OUTPUT ${FLEX_TARGET_outputs}
COMMAND ${FLEX_EXECUTABLE}
ARGS ${FLEX_EXECUTABLE_opts} -o${Output} ${Input}
DEPENDS ${Input}
@@ -184,6 +195,11 @@ if(FLEX_EXECUTABLE)
set(FLEX_${Name}_OUTPUTS ${Output})
set(FLEX_${Name}_INPUT ${Input})
set(FLEX_${Name}_COMPILE_FLAGS ${FLEX_EXECUTABLE_opts})
+ if("${FLEX_TARGET_ARG_DEFINES_FILE}" STREQUAL "")
+ set(FLEX_${Name}_OUTPUT_HEADER "")
+ else()
+ set(FLEX_${Name}_OUTPUT_HEADER ${FLEX_TARGET_ARG_DEFINES_FILE})
+ endif()
endif()
endmacro()
#============================================================
@@ -196,11 +212,11 @@ if(FLEX_EXECUTABLE)
macro(ADD_FLEX_BISON_DEPENDENCY FlexTarget BisonTarget)
if(NOT FLEX_${FlexTarget}_OUTPUTS)
- message(SEND_ERROR "Flex target `${FlexTarget}' does not exists.")
+ message(SEND_ERROR "Flex target `${FlexTarget}' does not exist.")
endif()
if(NOT BISON_${BisonTarget}_OUTPUT_HEADER)
- message(SEND_ERROR "Bison target `${BisonTarget}' does not exists.")
+ message(SEND_ERROR "Bison target `${BisonTarget}' does not exist.")
endif()
set_source_files_properties(${FLEX_${FlexTarget}_OUTPUTS}
--
1.9.4.msysgit.0
|