Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cmake/qibuild/qibuild-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/dependencies.cmake)
include(${CMAKE_CURRENT_BINARY_DIR}/dependencies.cmake)
endif()

# If someone is using qibuild configure, includes
# the project.cmake file
if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/project.cmake)
include(${CMAKE_CURRENT_BINARY_DIR}/project.cmake)
endif()

# remove qi_tests.json
# Note:
# this will fail silently if the file does not exist
Expand Down
5 changes: 3 additions & 2 deletions python/qibuild/cmake_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,14 @@ def bootstrap_projects(self):
"""
projects = self.deps_solver.get_dep_projects(self.projects,
["build", "runtime", "test"])
# subtle diffs here: dependencies.cmake must be written for *all* projects,
# with the build dependencies
# subtle diffs here: dependencies.cmake and project.cmake must be written
# for *all* projects, with the build dependencies
for project in projects:
sdk_dirs = self.get_sdk_dirs_for_project(project)
host_dirs = self.get_host_dirs(project)
if not project.meta:
project.write_dependencies_cmake(sdk_dirs, host_dirs=host_dirs)
project.write_project_cmake()

def get_sdk_dirs_for_project(self, project):
sdk_dirs = self.deps_solver.get_sdk_dirs(project, ["build", "test"])
Expand Down
18 changes: 18 additions & 0 deletions python/qibuild/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,24 @@ def using_make(self):
def verbose_make(self):
return self.build_config.verbose_make

def write_project_cmake(self):
""" Write the project.cmake file. This will be read by
qibuild-config.cmake to set QI_SDK_VERSION.
"""
to_write = """
#############################################
#QIBUILD AUTOGENERATED FILE. DO NOT EDIT.
#############################################

# Add qiproject version to CMake
set(QI_SDK_VERSION %s CACHE STRING "" FORCE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe QI_SDK_ prefix is already used elsewhere.

Mabye use QI_PROJECT_VERSION instead ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I'll fix it.

""" % self.version


qisys.sh.mkdir(self.build_directory, recursive=True)
proj_cmake = os.path.join(self.build_directory, "project.cmake")
qisys.sh.write_file_if_different(to_write, proj_cmake)

def write_dependencies_cmake(self, sdk_dirs, host_dirs=None):
""" Write the dependencies.cmake file. This will be read by
qibuild-config.cmake to set CMAKE_PREFIX_PATH and
Expand Down
9 changes: 9 additions & 0 deletions python/qibuild/test/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@

import pytest

def test_project_cmake(build_worktree):
hello_proj = build_worktree.create_project("hello")
hello_proj.write_project_cmake()
proj_cmake = os.path.join(hello_proj.build_directory,
"project.cmake")
# only way to check this really works is to build some
# cmake projects, so no other assertions here
assert os.path.exists(proj_cmake)

def test_dependencies_cmake(build_worktree):
hello_proj = build_worktree.create_project("hello")
hello_proj.write_dependencies_cmake(list())
Expand Down