aboutsummaryrefslogtreecommitdiff
path: root/cfront
diff options
context:
space:
mode:
Diffstat (limited to 'cfront')
-rw-r--r--cfront/CMakeLists.txt53
-rw-r--r--cfront/cmake/modules/CFrontConfig.cmake.in8
-rw-r--r--cfront/cmake/modules/CFrontConfigVersion.cmake.in13
-rw-r--r--cfront/cmake/modules/CMakeLists.txt35
-rw-r--r--cfront/include/cfront/.gitkeep0
-rw-r--r--cfront/lib/CMakeLists.txt3
-rw-r--r--cfront/tools/CMakeLists.txt3
7 files changed, 115 insertions, 0 deletions
diff --git a/cfront/CMakeLists.txt b/cfront/CMakeLists.txt
new file mode 100644
index 0000000..f0c4d0a
--- /dev/null
+++ b/cfront/CMakeLists.txt
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+cmake_minimum_required(VERSION 3.25)
+include("${CMAKE_CURRENT_LIST_DIR}/../cmake/Modules/CMakePolicy.cmake" NO_POLICY_SCOPE)
+include("${CMAKE_CURRENT_LIST_DIR}/../cmake/Modules/RCCVersion.cmake")
+
+project(CFront VERSION "${RCC_VERSION}" LANGUAGES C CXX)
+
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
+ message(FATAL_ERROR "CFront requires an out-of-source build.")
+endif()
+
+if(NOT TARGET RCCHeaders)
+ set(CFRONT_STANDALONE_BUILD ON)
+ find_package(RCC ${RCC_VERSION} EXACT CONFIG REQUIRED HINTS "${RCC_CMAKE_DIR}")
+else()
+ set(CFRONT_STANDALONE_BUILD OFF)
+endif()
+list(PREPEND CMAKE_MODULE_PATH
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" "${RCC_CMAKE_DIR}")
+include(GNUInstallDirs)
+include(HandleRCCOptions)
+include(AddCFront)
+if(CFRONT_STANDALONE_BUILD)
+ add_compile_definitions(${RCC_DEFINITIONS})
+ foreach(cfrontDefinition IN LISTS RCC_DEFINITIONS)
+ list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D${cfrontDefinition}")
+ endforeach()
+ rcc_configure_options()
+ rcc_configure_output_directories()
+endif()
+set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Export the compilation database")
+
+set(CFRONT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+set(CFRONT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+file(MAKE_DIRECTORY "${CFRONT_BINARY_DIR}/include/cfront")
+add_library(CFrontHeaders INTERFACE)
+target_compile_features(CFrontHeaders INTERFACE cxx_std_23)
+target_include_directories(CFrontHeaders INTERFACE
+ "$<BUILD_INTERFACE:${CFRONT_SOURCE_DIR}/include>"
+ "$<BUILD_INTERFACE:${CFRONT_BINARY_DIR}/include>"
+ "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
+target_link_libraries(CFrontHeaders INTERFACE RCCHeaders)
+install(TARGETS CFrontHeaders EXPORT CFrontTargets)
+install(DIRECTORY include/cfront DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
+ FILES_MATCHING PATTERN "*.h" PATTERN "*.inc" PATTERN "*.def")
+install(DIRECTORY "${CFRONT_BINARY_DIR}/include/cfront" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
+ FILES_MATCHING PATTERN "*.h" PATTERN "*.inc" PATTERN "*.def"
+ PATTERN "CMakeFiles" EXCLUDE PATTERN "config.h" EXCLUDE)
+
+add_subdirectory(lib)
+add_subdirectory(tools)
+add_subdirectory(cmake/modules)
diff --git a/cfront/cmake/modules/CFrontConfig.cmake.in b/cfront/cmake/modules/CFrontConfig.cmake.in
new file mode 100644
index 0000000..3b1a800
--- /dev/null
+++ b/cfront/cmake/modules/CFrontConfig.cmake.in
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+@PACKAGE_INIT@
+
+include(CMakeFindDependencyMacro)
+find_dependency(RCC @RCC_VERSION@ EXACT CONFIG HINTS "@CFRONT_PACKAGE_RCC_CMAKE_DIR@")
+set(CFRONT_CMAKE_DIR "@CFRONT_PACKAGE_MODULE_DIR@")
+include("${CMAKE_CURRENT_LIST_DIR}/CFrontTargets.cmake")
diff --git a/cfront/cmake/modules/CFrontConfigVersion.cmake.in b/cfront/cmake/modules/CFrontConfigVersion.cmake.in
new file mode 100644
index 0000000..f7d5ea4
--- /dev/null
+++ b/cfront/cmake/modules/CFrontConfigVersion.cmake.in
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+set(PACKAGE_VERSION "@PROJECT_VERSION@")
+
+# Match major and minor versions; accept the requested patch version or newer.
+if("@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@" VERSION_EQUAL
+ "${PACKAGE_FIND_VERSION_MAJOR}.${PACKAGE_FIND_VERSION_MINOR}"
+ AND NOT "@PROJECT_VERSION_PATCH@" VERSION_LESS "${PACKAGE_FIND_VERSION_PATCH}")
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ if("@PROJECT_VERSION_PATCH@" VERSION_EQUAL "${PACKAGE_FIND_VERSION_PATCH}")
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif()
+endif()
diff --git a/cfront/cmake/modules/CMakeLists.txt b/cfront/cmake/modules/CMakeLists.txt
new file mode 100644
index 0000000..634ba34
--- /dev/null
+++ b/cfront/cmake/modules/CMakeLists.txt
@@ -0,0 +1,35 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+include(CMakePackageConfigHelpers)
+
+set(cfrontPackageDir "${CFRONT_BINARY_DIR}/lib/cmake/CFront")
+set(cfrontInstallPackageDir "${CMAKE_INSTALL_LIBDIR}/cmake/CFront")
+set(CFRONT_PACKAGE_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+if(CFRONT_STANDALONE_BUILD)
+ set(CFRONT_PACKAGE_RCC_CMAKE_DIR "${RCC_DIR}")
+else()
+ set(CFRONT_PACKAGE_RCC_CMAKE_DIR "${RCC_BINARY_DIR}/lib/cmake/RCC")
+endif()
+configure_package_config_file(CFrontConfig.cmake.in
+ "${cfrontPackageDir}/CFrontConfig.cmake"
+ INSTALL_DESTINATION "${cfrontPackageDir}"
+ NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO)
+export(EXPORT CFrontTargets FILE "${cfrontPackageDir}/CFrontTargets.cmake")
+
+set(CFRONT_PACKAGE_MODULE_DIR "\${CMAKE_CURRENT_LIST_DIR}")
+if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
+ set(CFRONT_PACKAGE_RCC_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/RCC")
+else()
+ set(CFRONT_PACKAGE_RCC_CMAKE_DIR "\${PACKAGE_PREFIX_DIR}/${CMAKE_INSTALL_LIBDIR}/cmake/RCC")
+endif()
+configure_package_config_file(CFrontConfig.cmake.in CFrontConfig.install.cmake
+ INSTALL_DESTINATION "${cfrontInstallPackageDir}"
+ NO_SET_AND_CHECK_MACRO NO_CHECK_REQUIRED_COMPONENTS_MACRO)
+configure_file(CFrontConfigVersion.cmake.in
+ "${cfrontPackageDir}/CFrontConfigVersion.cmake" @ONLY)
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/CFrontConfig.install.cmake"
+ DESTINATION "${cfrontInstallPackageDir}" RENAME CFrontConfig.cmake)
+install(FILES "${cfrontPackageDir}/CFrontConfigVersion.cmake" AddCFront.cmake
+ DESTINATION "${cfrontInstallPackageDir}")
+install(EXPORT CFrontTargets FILE CFrontTargets.cmake
+ DESTINATION "${cfrontInstallPackageDir}")
diff --git a/cfront/include/cfront/.gitkeep b/cfront/include/cfront/.gitkeep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/cfront/include/cfront/.gitkeep
diff --git a/cfront/lib/CMakeLists.txt b/cfront/lib/CMakeLists.txt
new file mode 100644
index 0000000..2efe23c
--- /dev/null
+++ b/cfront/lib/CMakeLists.txt
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+# Add frontend libraries here as their implementations are introduced.
diff --git a/cfront/tools/CMakeLists.txt b/cfront/tools/CMakeLists.txt
new file mode 100644
index 0000000..dad636b
--- /dev/null
+++ b/cfront/tools/CMakeLists.txt
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+# Add frontend tools here as their implementations are introduced.