summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBaruch Sterin <baruchs@gmail.com>2015-10-21 22:56:15 -0700
committerBaruch Sterin <baruchs@gmail.com>2015-10-21 22:56:15 -0700
commit9b3a358e6fba7ee6bd4811ed95f3c8c62e056152 (patch)
tree7f86a03f848f51a04b3cac754457afabe6f3fd97
parent28f2063caa7fb8864a63622a40f54bb70d1be08e (diff)
downloadabc-9b3a358e6fba7ee6bd4811ed95f3c8c62e056152.tar.gz
abc-9b3a358e6fba7ee6bd4811ed95f3c8c62e056152.tar.bz2
abc-9b3a358e6fba7ee6bd4811ed95f3c8c62e056152.zip
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.
-rw-r--r--.hgignore3
-rw-r--r--CMakeLists.txt30
-rw-r--r--Makefile9
3 files changed, 41 insertions, 1 deletions
diff --git a/.hgignore b/.hgignore
index 95c7dd87..66611e62 100644
--- a/.hgignore
+++ b/.hgignore
@@ -46,6 +46,9 @@ src/python/bdist
src/python/pyabc.py
src/python/pyabc_wrap.*
+.idea/
+build/
+
syntax: regexp
^libabc.a$
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 00000000..09bf5016
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,30 @@
+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})
diff --git a/Makefile b/Makefile
index e1ba1500..03fceceb 100644
--- a/Makefile
+++ b/Makefile
@@ -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