CMakeLists.txt, Makefile: fix a bug in passing the readline options

This commit is contained in:
Baruch Sterin 2015-11-07 19:48:11 -08:00
parent e50fc467fd
commit b18eb60301
2 changed files with 13 additions and 10 deletions

View File

@ -4,6 +4,13 @@ include(CMakeParseArguments)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
function(addprefix var prefix)
foreach( s ${ARGN} )
list(APPEND tmp "-I${s}")
endforeach()
set(${var} ${tmp} PARENT_SCOPE)
endfunction()
# filter out flags that are not appropriate for the compiler being used
function(target_compile_options_filtered target visibility)
foreach( flag ${ARGN} )
@ -26,9 +33,12 @@ endfunction()
project(abc)
if(READLINE_FOUND MATCHES TRUE)
addprefix(READLINE_INCLUDES_FLAGS "-I" ${READLINE_INCLUDES})
list(APPEND ABC_READLINE_FLAGS "ABC_READLINE_INCLUDES=${READLINE_INCLUDES_FLAGS}")
list(APPEND ABC_READLINE_FLAGS "ABC_READLINE_LIBRARIES=${READLINE_LIBRARIES}")
addprefix(ABC_READLINE_INCLUDES_FLAGS "-I" ${READLINE_INCLUDES})
string(REPLACE ";" " " ABC_READLINE_INCLUDES_FLAGS "${ABC_READLINE_INCLUDES_FLAGS}")
list(APPEND ABC_READLINE_FLAGS "ABC_READLINE_INCLUDES=${ABC_READLINE_INCLUDES_FLAGS}")
string(REPLACE ";" " " ABC_READLINE_LIBRARIES_FLAGS "${READLINE_LIBRARIES}")
list(APPEND ABC_READLINE_FLAGS "ABC_READLINE_LIBRARIES=${ABC_READLINE_LIBRARIES_FLAGS}")
elseif(READLINE_FOUND MATCHES FALSE)
list(APPEND ABC_READLINE_FLAGS "ABC_USE_NO_READLINE=1")
endif()

View File

@ -73,13 +73,6 @@ ifndef ABC_USE_NO_READLINE
$(info $(MSG_PREFIX)Using libreadline)
endif
# whether to use libreadline
ifndef ABC_USE_NO_READLINE
CFLAGS += -DABC_USE_READLINE
LIBS += -lreadline
$(info $(MSG_PREFIX)Using libreadline)
endif
# whether to compile with thread support
ifdef ABC_USE_NO_PTHREADS
CFLAGS += -DABC_USE_PTHREADS