Skip to content

Commit b76046a

Browse files
authored
Merge pull request #1444 from tdegeus/cmake
Adding CMake FindPython tip
2 parents 6d46481 + 7af0165 commit b76046a

File tree

1 file changed

+29
-16
lines changed

1 file changed

+29
-16
lines changed

src/maintainer/knowledge_base.rst

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,24 @@ On Windows, you can also use ``nmake`` to build, but that does not need to be ex
1919
- make # [not win]
2020
- ninja # [win]
2121
22-
For CMake projects using the `FindPython3 <https://cmake.org/cmake/help/git-stage/module/FindPython3.html>`__
23-
module, you can tell CMake which Python to use by passing ``-DPython3_EXECUTABLE="$PYTHON"``
24-
(macOS or Linux) or ``-DPython3_EXECUTABLE="%PYTHON%"`` (Windows) as a command line option.
22+
For CMake projects using the `FindPython <https://cmake.org/cmake/help/git-stage/module/FindPython.html>`__
23+
module, you can tell CMake which Python to use by passing ``-DPython_EXECUTABLE="$PYTHON"``
24+
(macOS or Linux) or ``-DPython_EXECUTABLE="%PYTHON%"`` (Windows) as a command line option.
2525
Older CMake projects may require similar, but slightly different options.
2626

27+
.. tip::
28+
29+
Don't forget that depending on which CMake module you use you have to use a different command:
30+
31+
- `FindPython <https://cmake.org/cmake/help/git-stage/module/FindPython.html>`__:
32+
``-DPython_EXECUTABLE=...``.
33+
- `FindPython3 <https://cmake.org/cmake/help/git-stage/module/FindPython3.html>`__:
34+
``-DPython3_EXECUTABLE=...``.
35+
- `FindPython2 <https://cmake.org/cmake/help/git-stage/module/FindPython2.html>`__:
36+
``-DPython2_EXECUTABLE=...``.
37+
38+
or if you are still on the deprecated `FindPythonLibs <https://cmake.org/cmake/help/latest/module/FindPythonLibs.html>`__: ``-DPYTHON_EXECUTABLE=...``.
39+
2740
Some optional, but useful CMake options:
2841

2942
- ``-DCMAKE_BUILD_TYPE=Release`` Configure as release build. This is better done on the initial
@@ -189,20 +202,20 @@ To skip building with a particular ``vc`` version, add a skip statement.
189202
requirements:
190203
build:
191204
- {{ compiler('cxx') }}
192-
205+
193206
Using vs2019
194207
-------------
195208

196-
To use ``vs2019`` make the following changes:
209+
To use ``vs2019`` make the following changes:
197210

198-
In conda_build_config.yaml file:
211+
In conda_build_config.yaml file:
199212

200213
.. code-block:: yaml
201214
202-
c_compiler:
203-
- vs2019
204-
cxx_compiler:
205-
- vs2019
215+
c_compiler:
216+
- vs2019
217+
cxx_compiler:
218+
- vs2019
206219
207220
208221
In conda-forge.yml file:
@@ -213,8 +226,8 @@ In conda-forge.yml file:
213226
settings_win:
214227
pool:
215228
vmImage: windows-2019
216-
217-
229+
230+
218231
219232
For example see the changes made in the ``conda_build_config.yaml`` and ``conda-forge.yml`` files in `this
220233
<https://github.com/conda-forge/libignition-physics-feedstock/commit/c586d765a2f5fd0ecf6da43c53315c898c9bf6bd>`_ PR.
@@ -259,12 +272,12 @@ Core Dependency Tree Packages (CDTs)
259272
------------------------------------
260273

261274
Dependencies outside of the ``conda-forge`` channel should be avoided (see :ref:`no_external_deps`).
262-
However, there are a few exceptions:
275+
However, there are a few exceptions:
263276

264-
Some dependencies are so close to the system that they are not packaged with ``conda-forge``.
265-
These dependencies have to be satisfied with *Core Dependency Tree* (CDT) packages.
277+
Some dependencies are so close to the system that they are not packaged with ``conda-forge``.
278+
These dependencies have to be satisfied with *Core Dependency Tree* (CDT) packages.
266279

267-
A CDT package consists of repackaged CentOS binaries from the appropriate version,
280+
A CDT package consists of repackaged CentOS binaries from the appropriate version,
268281
either 6 or 7 depending on user choice and platform. We manage the build of CDT
269282
packages using a centralized repo, `conda-forge/cdt-builds <https://github.com/conda-forge/cdt-builds>`_,
270283
as opposed to generating feedstocks for them. (Note that historically we did use feedstocks but this

0 commit comments

Comments
 (0)