aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2018-06-23 14:32:18 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2018-06-23 14:32:49 +0200
commit82ec1be31f2a13bca04cf1a6b69789c9cee0e535 (patch)
treefed19ab35ad400d2642da1c4a327d89b0ff90f36 /CMakeLists.txt
parentb63fdfbeab5abb390c5c2c7b069672c9c8e06c82 (diff)
downloadnextpnr-82ec1be31f2a13bca04cf1a6b69789c9cee0e535.tar.gz
nextpnr-82ec1be31f2a13bca04cf1a6b69789c9cee0e535.tar.bz2
nextpnr-82ec1be31f2a13bca04cf1a6b69789c9cee0e535.zip
Added BUILD_GUI, BUILD_PYTHON and BUILD_TESTS cmake options,
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt154
1 files changed, 102 insertions, 52 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1b05d296..5d41fcbe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,11 @@
# TODO: sensible minimum CMake version
cmake_minimum_required(VERSION 3.3)
project(nextpnr)
+
+option(BUILD_GUI "Build GUI" ON)
+option(BUILD_PYTHON "Build Python Integration" ON)
+option(BUILD_TESTS "Build GUI" OFF)
+
# List of families to build
set(FAMILIES dummy ice40)
set(CMAKE_CXX_STANDARD 11)
@@ -9,15 +14,24 @@ set(CMAKE_CXX_FLAGS_RELEASE "-Wall -fPIC -O3 -g")
set(CMAKE_DEFIN)
# List of Boost libraries to include
set(boost_libs filesystem thread program_options)
-# TODO: sensible minimum Python version
-find_package(PythonInterp 3.5 REQUIRED)
-find_package(PythonLibs 3.5 REQUIRED)
+
+if (BUILD_PYTHON)
+ # TODO: sensible minimum Python version
+ find_package(PythonInterp 3.5 REQUIRED)
+ find_package(PythonLibs 3.5 REQUIRED)
+else()
+ add_definitions("-DNO_PYTHON")
+endif()
find_package(Boost REQUIRED COMPONENTS ${boost_libs})
-# Find the Qt5 libraries
-find_package(Qt5 COMPONENTS Core Widgets OpenGL REQUIRED)
-find_package(OpenGL REQUIRED)
+if (BUILD_GUI)
+ # Find the Qt5 libraries
+ find_package(Qt5 COMPONENTS Core Widgets OpenGL REQUIRED)
+ find_package(OpenGL REQUIRED)
+else()
+ add_definitions("-DNO_GUI")
+endif()
# Get the latest abbreviated commit hash of the working branch
execute_process(
@@ -27,57 +41,64 @@ execute_process(
OUTPUT_STRIP_TRAILING_WHITESPACE
)
-add_subdirectory(3rdparty/googletest/googletest generated/3rdparty/googletest EXCLUDE_FROM_ALL)
-enable_testing()
+if (BUILD_TESTS)
+ add_subdirectory(3rdparty/googletest/googletest generated/3rdparty/googletest EXCLUDE_FROM_ALL)
+ enable_testing()
+endif()
-add_subdirectory(3rdparty/QtPropertyBrowser generated/3rdparty/QtPropertyBrowser)
+if (BUILD_GUI)
+ add_subdirectory(3rdparty/QtPropertyBrowser generated/3rdparty/QtPropertyBrowser)
+endif()
add_definitions("-DGIT_COMMIT_HASH=${GIT_COMMIT_HASH}")
+
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/common/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/generated/version.h
)
-# Find Boost::Python of a suitable version in a cross-platform way
-# Some distributions (Arch) call it libboost_python3, others such as Ubuntu
-# call it libboost_python35. In the latter case we must consider all minor versions
-# Original source: https://github.com/BVLC/caffe/blob/master/cmake/Dependencies.cmake#L148
-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})
+if (BUILD_PYTHON)
+ # Find Boost::Python of a suitable version in a cross-platform way
+ # Some distributions (Arch) call it libboost_python3, others such as Ubuntu
+ # call it libboost_python35. In the latter case we must consider all minor versions
+ # Original source: https://github.com/BVLC/caffe/blob/master/cmake/Dependencies.cmake#L148
+ 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})
- STRING(REGEX MATCHALL "([0-9.]+).[0-9]+" has_more_version ${version})
- if ("${has_more_version}" STREQUAL "")
- break()
- endif ()
-endwhile ()
+ 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})
-if (NOT Boost_PYTHON_FOUND)
- find_package(Boost COMPONENTS python3 ${boost_libs})
- if ("${Boost_LIBRARIES}" MATCHES ".*(python|PYTHON).*" )
- set(Boost_PYTHON_FOUND TRUE)
+ 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})
+ if ("${Boost_LIBRARIES}" MATCHES ".*(python|PYTHON).*" )
+ set(Boost_PYTHON_FOUND TRUE)
+ endif ()
endif ()
-endif ()
-if (NOT Boost_PYTHON_FOUND)
- STRING(REGEX REPLACE "([0-9]+\\.[0-9]+).*" "\\1" gentoo_version ${PYTHONLIBS_VERSION_STRING})
- find_package(Boost COMPONENTS python-${gentoo_version} ${boost_libs})
- if ("${Boost_LIBRARIES}" MATCHES ".*(python|PYTHON).*" )
- set(Boost_PYTHON_FOUND TRUE)
+ if (NOT Boost_PYTHON_FOUND)
+ STRING(REGEX REPLACE "([0-9]+\\.[0-9]+).*" "\\1" gentoo_version ${PYTHONLIBS_VERSION_STRING})
+ find_package(Boost COMPONENTS python-${gentoo_version} ${boost_libs})
+ if ("${Boost_LIBRARIES}" MATCHES ".*(python|PYTHON).*" )
+ set(Boost_PYTHON_FOUND TRUE)
+ endif ()
endif ()
-endif ()
-if (NOT Boost_PYTHON_FOUND )
- message( FATAL_ERROR "No version of Boost::Python 3.x could be found.")
-endif ()
+ if (NOT Boost_PYTHON_FOUND )
+ message( FATAL_ERROR "No version of Boost::Python 3.x could be found.")
+ endif ()
+endif()
include_directories(common/ frontend/json ${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS})
aux_source_directory(common/ COMMON_SRC_FILES)
@@ -91,33 +112,58 @@ endif(MINGW)
foreach (family ${FAMILIES})
string(TOUPPER ${family} ufamily)
- aux_source_directory(${family}/ ${ufamily}_FILES)
- aux_source_directory(tests/${family}/ ${ufamily}_TEST_FILES)
+ aux_source_directory(${family}/ ${ufamily}_FILES)
- add_subdirectory(gui generated/gui/${family})
+ if (BUILD_GUI)
+ add_subdirectory(gui generated/gui/${family})
+ endif()
# Add the CLI binary target
add_executable(nextpnr-${family} ${COMMON_FILES} ${${ufamily}_FILES} )
install(TARGETS nextpnr-${family} RUNTIME DESTINATION bin)
target_compile_definitions(nextpnr-${family} PRIVATE MAIN_EXECUTABLE)
- # Add the importable Python module target
- PYTHON_ADD_MODULE(nextpnrpy_${family} EXCLUDE_FROM_ALL ${COMMON_FILES} ${${ufamily}_FILES})
+ if (BUILD_PYTHON)
+ # Add the importable Python module target
+ PYTHON_ADD_MODULE(nextpnrpy_${family} EXCLUDE_FROM_ALL ${COMMON_FILES} ${${ufamily}_FILES})
+ endif()
+
# Add any new per-architecture targets here
+ if (BUILD_TESTS)
+ aux_source_directory(tests/${family}/ ${ufamily}_TEST_FILES)
+
+ add_executable(nextpnr-${family}-test ${${ufamily}_TEST_FILES} ${COMMON_FILES} ${${ufamily}_FILES})
+ target_link_libraries(nextpnr-${family}-test PRIVATE gtest_main)
- add_executable(nextpnr-${family}-test EXCLUDE_FROM_ALL ${${ufamily}_TEST_FILES} ${COMMON_FILES} ${${ufamily}_FILES})
- target_link_libraries(nextpnr-${family}-test PRIVATE gtest_main)
- add_test(${family}-test ${CMAKE_CURRENT_BINARY_DIR}/nextpnr-${family}-test)
+ add_test(${family}-test ${CMAKE_CURRENT_BINARY_DIR}/nextpnr-${family}-test)
+ endif()
# Set ${family_targets} to the list of targets being build for this family
- set(family_targets nextpnr-${family} nextpnrpy_${family} nextpnr-${family}-test)
+ set(family_targets nextpnr-${family})
+
+ if (BUILD_TESTS)
+ set(family_targets ${family_targets} nextpnr-${family}-test)
+ endif()
+
+ if (BUILD_PYTHON)
+ set(family_targets ${family_targets} nextpnrpy_${family})
+ endif()
+
# Include the family-specific CMakeFile
include(${family}/family.cmake)
foreach (target ${family_targets})
# Include family-specific source files to all family targets and set defines appropriately
- target_include_directories(${target} PRIVATE ${family}/ generated/ gui/${family}/ gui/)
- target_compile_definitions(${target} PRIVATE NEXTPNR_NAMESPACE=nextpnr_${family} ARCH_${ufamily} ARCHNAME=${family} QT_NO_KEYWORDS)
- target_link_libraries(${target} LINK_PUBLIC gui_${family} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES} ${GUI_LIBRARY_FILES_${ufamily}})
+ target_include_directories(${target} PRIVATE ${family}/ generated/)
+ target_compile_definitions(${target} PRIVATE NEXTPNR_NAMESPACE=nextpnr_${family} ARCH_${ufamily} ARCHNAME=${family})
+ target_link_libraries(${target} LINK_PUBLIC ${Boost_LIBRARIES})
+ if (BUILD_PYTHON)
+ target_link_libraries(${target} LINK_PUBLIC ${PYTHON_LIBRARIES})
+ endif()
+ if (BUILD_GUI)
+ target_include_directories(${target} PRIVATE gui/${family}/ gui/)
+ target_compile_definitions(${target} PRIVATE QT_NO_KEYWORDS)
+ target_link_libraries(${target} LINK_PUBLIC gui_${family} ${GUI_LIBRARY_FILES_${ufamily}})
+ endif()
endforeach (target)
endforeach (family)
@@ -133,3 +179,7 @@ add_custom_target(
-i
${CLANGFORMAT_FILES}
)
+
+unset(BUILD_GUI CACHE)
+unset(BUILD_PYTHON CACHE)
+unset(BUILD_TESTS CACHE)