aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorDavid Shah <davey1576@gmail.com>2018-06-01 11:58:31 +0200
committerDavid Shah <davey1576@gmail.com>2018-06-02 13:48:28 +0200
commitee0a5374d8902f8f21be25a21ab20ae23b21c103 (patch)
treeacf8d6c980719ecaaff69ba35f4a2b4946c7344e /CMakeLists.txt
parentd3e54131e70db28399799329d8ba3c6271a9b5fb (diff)
downloadnextpnr-ee0a5374d8902f8f21be25a21ab20ae23b21c103.tar.gz
nextpnr-ee0a5374d8902f8f21be25a21ab20ae23b21c103.tar.bz2
nextpnr-ee0a5374d8902f8f21be25a21ab20ae23b21c103.zip
Add a CMake based build system
Signed-off-by: David Shah <davey1576@gmail.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt59
1 files changed, 59 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 00000000..a17a07ce
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,59 @@
+# TODO: sensible minimum CMake version
+cmake_minimum_required(VERSION 3.3)
+project(nextpnr)
+
+set(FAMILIES dummy ice40)
+set(CMAKE_CXX_STANDARD 11)
+# set(CMAKE_CXX_FLAGS "-Wall -pedantic -Wextra -Werror")
+set(CMAKE_DEFIN)
+set(boost_libs filesystem thread)
+# TODO: sensible minimum Python version
+find_package(PythonInterp 3.5 REQUIRED)
+find_package(PythonLibs 3.5 REQUIRED)
+
+find_package(Boost REQUIRED COMPONENTS ${boost_libs})
+
+# Find Boost::Python of a suitable version in a cross-platform way
+
+set(version ${PYTHONLIBS_VERSION_STRING})
+
+STRING(REGEX REPLACE "[^0-9]" "" boost_py_version ${version})
+find_package(Boost COMPONENTS "python-py${boost_py_version}" ${boost_libs})
+set(Boost_PYTHON_FOUND ${Boost_PYTHON-PY${boost_py_version}_FOUND})
+
+while (NOT "${version}" STREQUAL "" AND NOT Boost_PYTHON_FOUND)
+ STRING(REGEX REPLACE "([0-9.]+).[0-9]+" "\\1" version ${version})
+
+ STRING(REGEX REPLACE "[^0-9]" "" boost_py_version ${version})
+ find_package(Boost COMPONENTS "python-py${boost_py_version}" ${boost_libs})
+ set(Boost_PYTHON_FOUND ${Boost_PYTHON-PY${boost_py_version}_FOUND})
+
+ STRING(REGEX MATCHALL "([0-9.]+).[0-9]+" has_more_version ${version})
+ if ("${has_more_version}" STREQUAL "")
+ break()
+ endif ()
+endwhile ()
+
+if (NOT Boost_PYTHON_FOUND)
+ find_package(Boost COMPONENTS python3 ${boost_libs})
+endif ()
+
+# TODO: Find and include Qt
+
+include_directories(common/ ${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS})
+aux_source_directory(common/ COMMON_FILES)
+
+foreach (family ${FAMILIES})
+ string(TOUPPER ${family} ufamily)
+ aux_source_directory(${family}/ ${ufamily}_FILES)
+ add_executable(nextpnr-${family} ${COMMON_FILES} ${${ufamily}_FILES})
+ # TODO: also build an importable Python module
+ # PYTHON_ADD_MODULE(pynextpnr_${family} ${COMMON_FILES} ${${ufamily}_FILES})
+ set(family_targets nextpnr-${family})
+ include(${family}/family.cmake)
+ foreach (target ${family_targets})
+ target_include_directories(${target} PRIVATE ${family}/)
+ target_compile_definitions(${target} PRIVATE ARCH_${ufamily} ARCHNAME="${family}")
+ target_link_libraries(${target} LINK_PUBLIC ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
+ endforeach (target)
+endforeach (family)