Commit 9b3a358e by Baruch Sterin

Makefile: Add a CMakeLists.txt that uses the regular Makefile to compute flags…

Makefile: Add a CMakeLists.txt that uses the regular Makefile to compute flags and source file. This is a ugly hack, mainly to allow the use of CLion with ABC. Include some changes in the Makefile to support that.
parent 28f2063c
......@@ -46,6 +46,9 @@ src/python/bdist
src/python/pyabc.py
src/python/pyabc_wrap.*
.idea/
build/
syntax: regexp
^libabc.a$
......
cmake_minimum_required(VERSION 3.1.0)
project(abc)
execute_process(
COMMAND make ABC_MAKE_NO_DEPS=1 cmake_info
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE MAKE_OUTPUT
)
function(extract_var SEPARATOR DEST_VARIABLE MAKE_OUTPUT)
string(REGEX MATCH "${SEPARATOR} .* ${SEPARATOR}" TMP "${MAKE_OUTPUT}")
string(REGEX REPLACE "${SEPARATOR} (.*) ${SEPARATOR}" "\\1" TMP "${TMP}")
separate_arguments(TMP)
set(${DEST_VARIABLE} ${TMP} PARENT_SCOPE)
endfunction()
extract_var(SEPARATOR_SRC ABC_SRC ${MAKE_OUTPUT})
extract_var(SEPARATOR_LIBS ABC_LIBS ${MAKE_OUTPUT})
extract_var(SEPARATOR_CFLAGS ABC_CFLAGS ${MAKE_OUTPUT})
add_executable(abc ${ABC_SRC})
target_include_directories(abc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src )
target_compile_options(abc PRIVATE ${ABC_CFLAGS} )
target_link_libraries(abc PRIVATE ${ABC_LIBS})
......@@ -125,7 +125,7 @@ CXXFLAGS += $(CFLAGS)
SRC :=
GARBAGE := core core.* *.stackdump ./tags $(PROG) arch_flags
.PHONY: all default tags clean docs
.PHONY: all default tags clean docs cmake_info
include $(patsubst %, %/module.make, $(MODULES))
......@@ -163,7 +163,9 @@ DEP := $(OBJ:.o=.d)
@echo "$(MSG_PREFIX)\`\` Generating dependency:" $(LOCAL_PATH)/$<
$(VERBOSE)./depends.sh $(CXX) `dirname $*.cpp` $(OPTFLAGS) $(INCLUDES) $(CXXFLAGS) $*.cpp > $@
ifndef ABC_MAKE_NO_DEPS
-include $(DEP)
endif
# Actual targets
......@@ -188,3 +190,8 @@ lib$(PROG).a: $(OBJ)
docs:
@echo "$(MSG_PREFIX)\`\` Building documentation." $(notdir $@)
$(VERBOSE)doxygen doxygen.conf
cmake_info:
@echo SEPARATOR_CFLAGS $(CFLAGS) SEPARATOR_CFLAGS
@echo SEPARATOR_LIBS $(LIBS) SEPARATOR_LIBS
@echo SEPARATOR_SRC $(SRC) SEPARATOR_SRC
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