Skip to content

Commit 19dbcca

Browse files
committed
tooling: Fix configure target from Makefile.package not working
This was not working reliably for two reasons: 1. `${BUILD_DIR}/CMakeCache.txt` is not where `CMakeCache.txt` is located anymore. So using this as a dependency didn't exactly work. 2. The arguments `--configure`, `--build`, `--test`, `--install` to the `conan build` command only set `self.should_configure`, `self.should_build`, etc. We need to check in the conanfile for these variables and act accordingly.
1 parent aadfa06 commit 19dbcca

File tree

17 files changed

+128
-80
lines changed

17 files changed

+128
-80
lines changed

Makefile.all

+1-2
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ help::
171171
echo
172172

173173
$(call make_select_target, all-select, "build selected packages", "[in-source]")
174-
$(call make_select_target, conan-select, "configure Conan and get dependencies", "[in-source]")
175-
$(call make_select_target, configure-select, "configure CMake packages", "[in-source]")
174+
$(call make_select_target, configure-select, "install dependencies and configure packages", "[in-source]")
176175
$(call make_select_target, test-select, "run CMake tests if they are available", "[in-source]")
177176
$(call make_select_target, export-pkg-select, "export build artifacts to Conan cache", "[in-source]")
178177
$(call make_select_target, clean-select, "remove build artifacts", "[in-source]")

Makefile.package

+11-16
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ BUILD_DIR := build
7979

8080
# Don't change these unless you know what you are doing.
8181
BUILD_CONANINFO := ${BUILD_DIR}/conanbuildinfo.txt
82-
BUILD_CMAKECACHE := ${BUILD_DIR}/CMakeCache.txt
8382
BUILD_LOCKFILE := ${BUILD_DIR}/conan.lock
8483

8584
# Default Conan build policy to use when installing Conan dependencies
@@ -202,8 +201,7 @@ ifeq (${BUILD_IN_SOURCE}, true)
202201
$(call print_help_target, uneditable, "instruct Conan to use local cache")
203202
echo
204203
$(call print_help_target, all, "build the package", "[in-source]")
205-
$(call print_help_target, conan, "configure Conan and install dependencies", "[in-source]")
206-
$(call print_help_target, configure, "configure CMake package", "[in-source]")
204+
$(call print_help_target, configure, "install dependencies and configure package", "[in-source]")
207205
$(call print_help_target, test, "run CMake tests if they are available", "[in-source]")
208206
$(call print_help_target, export-pkg, "export build artifacts to Conan cache", "[in-source]")
209207
ifeq (${CLEAN_SOURCE_DIR}, true)
@@ -423,13 +421,16 @@ clean:
423421
#
424422
rm -rf "${BUILD_DIR}"
425423
rm -rf __pycache__
424+
rm -f CMakeUserPresets.json
425+
rm -f compile_commands.json
426+
rm -f graph_info.json
426427
ifeq (${CLEAN_SOURCE_DIR}, true)
427428
[ "${SOURCE_DIR}" != "." ] && rm -rf "${SOURCE_DIR}"
428429
endif
429430

430431
ifeq (${BUILD_IN_SOURCE}, false)
431-
.PHONY: all conan configure test export-pkg
432-
all conan configure test export-pkg ${SOURCE_DIR} ${SOURCE_CMAKELISTS} ${BUILD_CONANINFO} ${BUILD_CMAKECACHE}:
432+
.PHONY: all configure test export-pkg
433+
all configure test export-pkg ${SOURCE_DIR} ${SOURCE_CMAKELISTS} ${BUILD_CONANINFO}:
433434
@echo "Error: [in-source] targets are not supported for this package."
434435
@echo "Note: please use [conan-cache] targets, such as 'package'."
435436
exit 1
@@ -440,11 +441,9 @@ all: ${BUILD_CONANINFO} | ${SOURCE_DIR}
440441
#
441442
conan build . --source-folder="${SOURCE_DIR}" --install-folder="${BUILD_DIR}"
442443

443-
.PHONY: conan
444-
conan: ${BUILD_CONANINFO}
445-
446444
.PHONY: configure
447-
configure: ${BUILD_CMAKECACHE}
445+
configure: ${BUILD_CONANINFO}
446+
ln -rsf "$$(dirname $$(dirname $$(jq -r '.include[0]' CMakeUserPresets.json)))/compile_commands.json"
448447

449448
.PHONY: test
450449
test:
@@ -481,15 +480,11 @@ ${SOURCE_DIR}:
481480

482481
${SOURCE_CMAKELISTS}: | ${SOURCE_DIR}
483482

484-
${BUILD_CONANINFO}: ${SOURCE_CONANFILE} ${BUILD_LOCKFILE}
485-
# Install package dependencies and prepare in-source build.
483+
${BUILD_CONANINFO}: ${SOURCE_CONANFILE} ${BUILD_LOCKFILE} ${SOURCE_CMAKELISTS}
484+
# Install package dependencies and configure in-source build.
486485
#
487486
mkdir -p "${BUILD_DIR}"
488487
conan install . ${PACKAGE_FQN} --install-folder="${BUILD_DIR}" --build=${BUILD_POLICY} ${ALL_OPTIONS}
489-
touch ${BUILD_CONANINFO}
490-
491-
${BUILD_CMAKECACHE}: ${SOURCE_CMAKELISTS} ${BUILD_CONANINFO}
492-
# Configure in-source build with CMake.
493-
#
494488
conan build --configure . --source-folder="${SOURCE_DIR}" --install-folder="${BUILD_DIR}"
489+
touch ${BUILD_CONANINFO}
495490
endif

engine/conanfile.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,17 @@ def generate(self):
7474

7575
def build(self):
7676
cm = cmake.CMake(self)
77-
cm.configure()
78-
cm.build()
79-
cm.test()
77+
if self.should_configure:
78+
cm.configure()
79+
if self.should_build:
80+
cm.build()
81+
if self.should_test:
82+
cm.test()
8083

8184
def package(self):
8285
cm = cmake.CMake(self)
83-
cm.install()
86+
if self.should_install:
87+
cm.install()
8488

8589
def package_id(self):
8690
self.info.requires["boost"].full_package_mode()

fable/conanfile.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,17 @@ def generate(self):
6363

6464
def build(self):
6565
cm = cmake.CMake(self)
66-
cm.configure()
67-
cm.build()
68-
cm.test()
66+
if self.should_configure:
67+
cm.configure()
68+
if self.should_build:
69+
cm.build()
70+
if self.should_test:
71+
cm.test()
6972

7073
def package(self):
7174
cm = cmake.CMake(self)
72-
cm.install()
75+
if self.should_install:
76+
cm.install()
7377

7478
def package_id(self):
7579
self.info.requires["boost"].full_package_mode()

models/conanfile.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,17 @@ def generate(self):
6060

6161
def build(self):
6262
cm = cmake.CMake(self)
63-
cm.configure()
64-
cm.build()
65-
cm.test()
63+
if self.should_configure:
64+
cm.configure()
65+
if self.should_build:
66+
cm.build()
67+
if self.should_test:
68+
cm.test()
6669

6770
def package(self):
6871
cm = cmake.CMake(self)
69-
cm.install()
72+
if self.should_install:
73+
cm.install()
7074

7175
def package_id(self):
7276
self.info.requires["boost"].full_package_mode()

oak/conanfile.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,17 @@ def generate(self):
5959

6060
def build(self):
6161
cm = cmake.CMake(self)
62-
cm.configure()
63-
cm.build()
64-
cm.test()
62+
if self.should_configure:
63+
cm.configure()
64+
if self.should_build:
65+
cm.build()
66+
if self.should_test:
67+
cm.test()
6568

6669
def package(self):
6770
cm = cmake.CMake(self)
68-
cm.install()
71+
if self.should_install:
72+
cm.install()
6973

7074
def package_id(self):
7175
del self.info.options.pedantic

optional/vtd/conanfile.py

+14-10
Original file line numberDiff line numberDiff line change
@@ -112,21 +112,25 @@ def generate(self):
112112

113113
def build(self):
114114
cm = cmake.CMake(self)
115-
cm.configure()
116-
cm.build()
117-
cm.test()
115+
if self.should_configure:
116+
cm.configure()
117+
if self.should_build:
118+
cm.build()
119+
if self.should_test:
120+
cm.test()
118121

119122
def package(self):
120123
vtd_api_version = self.dependencies["vtd-api"].ref.version
121124

122125
cm = cmake.CMake(self)
123-
cm.install()
124-
self.copy("vtd-launch", dst="bin", src=f"{self.source_folder}/bin")
125-
self.copy(
126-
"*.tar",
127-
dst=self._setup_folder,
128-
src=f"{self.source_folder}/{self._setup_folder}/{vtd_api_version}"
129-
)
126+
if self.should_install:
127+
cm.install()
128+
self.copy("vtd-launch", dst="bin", src=f"{self.source_folder}/bin")
129+
self.copy(
130+
"*.tar",
131+
dst=self._setup_folder,
132+
src=f"{self.source_folder}/{self._setup_folder}/{vtd_api_version}"
133+
)
130134

131135
def package_id(self):
132136
# Changes in a dependency's package_id need to be accounted for since

optional/vtd/vendor/vtd-api-2.2.0/conanfile.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,16 @@ def generate(self):
4848

4949
def build(self):
5050
cm = cmake.CMake(self)
51-
cm.configure()
52-
cm.build()
51+
if self.should_configure:
52+
cm.configure()
53+
if self.should_build:
54+
cm.build()
5355

5456
def package(self):
5557
cm = cmake.CMake(self)
56-
cm.install()
57-
files.copy(self, "Develop", src="src", dst=".")
58+
if self.should_install:
59+
cm.install()
60+
files.copy(self, "Develop", src="src", dst=".")
5861

5962
def package_info(self):
6063
self.cpp_info.set_property("cmake_find_mode", "both")

optional/vtd/vendor/vtd-api-2022.3/conanfile.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,16 @@ def generate(self):
4848

4949
def build(self):
5050
cm = cmake.CMake(self)
51-
cm.configure()
52-
cm.build()
51+
if self.should_configure:
52+
cm.configure()
53+
if self.should_build:
54+
cm.build()
5355

5456
def package(self):
5557
cm = cmake.CMake(self)
56-
cm.install()
57-
files.copy(self, "Develop", src="src", dst=".")
58+
if self.should_install:
59+
cm.install()
60+
files.copy(self, "Develop", src="src", dst=".")
5861

5962
def package_info(self):
6063
self.cpp_info.set_property("cmake_find_mode", "both")

plugins/basic/conanfile.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,17 @@ def generate(self):
5757

5858
def build(self):
5959
cm = cmake.CMake(self)
60-
cm.configure()
61-
cm.build()
62-
cm.test()
60+
if self.should_configure:
61+
cm.configure()
62+
if self.should_build:
63+
cm.build()
64+
if self.should_test:
65+
cm.test()
6366

6467
def package(self):
6568
cm = cmake.CMake(self)
66-
cm.install()
69+
if self.should_install:
70+
cm.install()
6771

6872
def package_id(self):
6973
self.info.requires["boost"].full_package_mode()

plugins/gndtruth_extractor/conanfile.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,17 @@ def generate(self):
5656

5757
def build(self):
5858
cm = cmake.CMake(self)
59-
cm.configure()
60-
cm.build()
61-
cm.test()
59+
if self.should_configure:
60+
cm.configure()
61+
if self.should_build:
62+
cm.build()
63+
if self.should_test:
64+
cm.test()
6265

6366
def package(self):
6467
cm = cmake.CMake(self)
65-
cm.install()
68+
if self.should_install:
69+
cm.install()
6670

6771
def package_id(self):
6872
self.info.requires["boost"].full_package_mode()

plugins/minimator/conanfile.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,15 @@ def generate(self):
5656

5757
def build(self):
5858
cm = cmake.CMake(self)
59-
cm.configure()
60-
cm.build()
59+
if self.should_configure:
60+
cm.configure()
61+
if self.should_build:
62+
cm.build()
6163

6264
def package(self):
6365
cm = cmake.CMake(self)
64-
cm.install()
66+
if self.should_install:
67+
cm.install()
6568

6669
def package_id(self):
6770
self.info.requires["boost"].full_package_mode()

plugins/mocks/conanfile.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,15 @@ def generate(self):
5353

5454
def build(self):
5555
cm = cmake.CMake(self)
56-
cm.configure()
57-
cm.build()
56+
if self.should_configure:
57+
cm.configure()
58+
if self.should_build:
59+
cm.build()
5860

5961
def package(self):
6062
cm = cmake.CMake(self)
61-
cm.install()
63+
if self.should_install:
64+
cm.install()
6265

6366
def package_id(self):
6467
self.info.requires["boost"].full_package_mode()

plugins/noisy_sensor/conanfile.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,17 @@ def generate(self):
5656

5757
def build(self):
5858
cm = cmake.CMake(self)
59-
cm.configure()
60-
cm.build()
61-
cm.test()
59+
if self.should_configure:
60+
cm.configure()
61+
if self.should_build:
62+
cm.build()
63+
if self.should_test:
64+
cm.test()
6265

6366
def package(self):
6467
cm = cmake.CMake(self)
65-
cm.install()
68+
if self.should_install:
69+
cm.install()
6670

6771
def package_id(self):
6872
self.info.requires["boost"].full_package_mode()

plugins/speedometer/conanfile.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,15 @@ def generate(self):
5353

5454
def build(self):
5555
cm = cmake.CMake(self)
56-
cm.configure()
57-
cm.build()
56+
if self.should_configure:
57+
cm.configure()
58+
if self.should_build:
59+
cm.build()
5860

5961
def package(self):
6062
cm = cmake.CMake(self)
61-
cm.install()
63+
if self.should_install:
64+
cm.install()
6265

6366
def package_id(self):
6467
self.info.requires["boost"].full_package_mode()

plugins/virtue/conanfile.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,15 @@ def generate(self):
5353

5454
def build(self):
5555
cm = cmake.CMake(self)
56-
cm.configure()
57-
cm.build()
56+
if self.should_configure:
57+
cm.configure()
58+
if self.should_build:
59+
cm.build()
5860

5961
def package(self):
6062
cm = cmake.CMake(self)
61-
cm.install()
63+
if self.should_install:
64+
cm.install()
6265

6366
def package_id(self):
6467
self.info.requires["boost"].full_package_mode()

0 commit comments

Comments
 (0)