Commit Graph

60 Commits

Author SHA1 Message Date
Furgo
44e4f53e61 Core: FreeCadMacros.cmake:fc_copy_sources ensure parent directory is created before copy or symlink creation
Fixes: #24432
2025-10-05 21:08:34 -05:00
Markus Reitböck
65d4088c9e cleanup remaining implementations of precompiled headers 2025-09-24 20:08:57 +02:00
Kacper Donat
e9c0118dd4 CMake: Detect changes in .pyi file with the same name 2025-04-24 16:40:24 -05:00
Joao Matos
1224143a99 CMake: Fix generate_from_py macro for temporary pyi files. 2025-03-26 12:18:02 +01:00
Joao Matos
ad4275fe50 CMake: Fix build dependency tracking for Python bindings generation.
This caused a rebuild to always happen due to incorrect dependency
tracking.

Fixes https://github.com/FreeCAD/FreeCAD/issues/20402.
2025-03-24 21:43:31 +01:00
Joao Matos
2e879c8982 Tools: Update binding generator. 2025-03-01 16:23:54 +00:00
Chris Hennes
dce7627c33 Merge pull request #19516 from tritao/tools-python-bindings-gen
Tools: Introduce a new Python-based C++ bindings generator
2025-02-24 16:39:24 +00:00
Chris Hennes
ab4f56fd04 CMake: Correct formatting to match existing 2025-02-22 20:48:44 -06:00
Chris Hennes
60a43400e2 CMake: Correct use of CACHE 2025-02-22 20:48:44 -06:00
Chris Hennes
bfeed4c05e CMake: PySide cleanup 2025-02-22 20:48:44 -06:00
Jacob Oursland
8fa089ba9c CMake: Remove unsupported DEPENDS args to CMake macros. 2025-02-22 20:41:15 -06:00
tritao
b97e695359 Tools: Introduce a Python-based API bindings template generator.
This extends the existing XML-based template generator to allow an
additional kind of Python-based input.

The Python code is read as source code to an AST to a typed model
equivalent to the existing XML model, and processed by the existing
code templates into compatible code.

This provides a few benefits, namely readability is much increased,
but more importantly, it allows associating the APIs with Python's new
typing information, which will allow to provide accurate type hinting
without additional downstream processing in the future.

Right now this is just a proof-of-concept but if the approach is
well received, then a more complete implementation can be done with
further conversion of existing binding files.

Here is an example of how it looks, though I still think the metadata
is too verbose and can be made to look nicer with some further work.

```python
from ..Base.Metadata import metadata
from ..Base.Persistence import PersistencePy
from typing import Any, Optional, List

@metadata(
    Father="PersistencePy",
    Name="DocumentPy",
    Twin="Document",
    TwinPointer="Document",
    Include="Gui/Document.h",
    Namespace="Gui",
    FatherInclude="Base/PersistencePy.h",
    FatherNamespace="Base"
)
class DocumentPy(PersistencePy):
    """
    This is a Document class.

    Author: Werner Mayer (wmayer@users.sourceforge.net)
    Licence: LGPL
    """

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        """
        Constructor for DocumentPy.
        """
        super(DocumentPy, self).__init__(*args, **kwargs)
        pass

    def show(self, objName: str) -> None:
        """
        show(objName) -> None

        Show an object.

        Parameters:
            objName (str): Name of the `Gui.ViewProvider` to show.
        """
        pass
```
2025-02-21 16:32:13 +00:00
tritao
537b51d038 CMake: Rename generate_from_py macro to generate_embed_from_py. 2025-02-21 13:18:36 +00:00
Joao Matos
aace8f7bee CMake: Modernize build files using outdated Python variables. 2025-02-16 10:21:26 -06:00
tritao
21d3cc0e78 Tools: Move bindings generator into generator folder. 2025-02-08 16:11:01 +00:00
João Matos
e697eddd06 CMake: Allow using symlinks for installed files. (#19043)
* CMake: Allow using symlinks for installed files.
2025-01-21 11:35:53 -06:00
Ladislav Michl
0931da2674 cMake: Fix searching for pip installed package libraries
Although this is a bit fragile way to search for package libraries
it does the job. A more robust solution may be desirable.
2024-08-14 09:46:51 +02:00
Chris Hennes
5e47f6804f Update for LibPack3 (#10337)
* cMake: Add base support for LibPack3

Minor changes to FreeCAD source code to support compiling with Qt 6.5 on MSVC,
and changes to cMake setup to support the new Libpack.

* NETGENPlugin: Fix compilation with MSVC and OCCT 7.8

* Material: Switch to Wrapped_ParseTupleAndKeywords for /fpermissive- on MSVC

* Base: Prevent accidental definition of MIN and MAX by MSVC

* cMake: Prevent accidentally finding an old LibPack

* Material: Wrap another ParseTuple call

* OCCT: Modify includes for 7.8.x

* Part: Change TNP code to use Wrapped_ParseTupleAndArgs

* Spreadsheet: Workaround for MSVC macro pollution

* Mesh: Workaround for MSVC macro pollution

* Base: Remove extra MSVC flag (moved to CMake)

* Tests: Fix compiling with /permissive-

* FEM: Fix Qt warnings about duplicate element names

* cMake: Ensure major version numbers are set

* Address review comments.

* cMake: Further tweaks for LibPack3

* cMake: Modify specification of compiler flags for MSVC

* Main: Remove QtQuick testing code

* cmake: Find Boost before SMESH (which uses it)

* Fixes for LibPack2

* cMake: Another try at importinhg VTK cleanly
2024-06-24 18:25:05 +02:00
wmayer
560cab6f31 clang/gcc: Add build option FREECAD_WARN_ERROR to force to make warnings into errors 2024-05-29 13:37:07 +02:00
wmayer
37a1b34c6a CMake: make sure to add RPATH to area-native library 2023-02-02 16:56:15 +01:00
andrea reale
83d3a916c0 remove QT4 references 2022-03-19 23:07:38 +01:00
wmayer
eff400620c add new CMake macro generate_from_any and extend PythonToCPP script to create source file from any text file 2019-10-14 22:20:59 +02:00
ezzieyguywuf
06af0151a9 Reverted FreeCadMacros.cmake to what is in master. 2019-09-26 18:55:33 +02:00
ezzieyguywuf
aa7419b203 Move logic out of CMakeLists.txt
This is an initial pass, simply moving the existing logic as-is. Future
PR's will attempt to refactor and improve the cmake stuff.
2019-09-26 18:54:45 +02:00
wmayer
ca51dec921 do not force CMAKE_INSTALL_LIBDIR to be an absolute path 2019-08-22 16:57:10 +02:00
wmayer
4b29b6c5d5 reduce compile time after each time cmake configure is executed (Version.h) 2018-08-21 14:06:33 +02:00
wmayer
2912fd7c62 macro to check for different input and output file and if needed replace output file 2018-08-21 13:52:42 +02:00
wmayer
8088aa159f CMake 2.8.12 and lower allowed the SOURCE signature in add_custom_command
In CMake 3.0 the policy CMP0050 was introduced where it could be set to OLD to keep this behaviour while for NEW an error was raised.
Since CMake 3.5.2 a warning comes up when using the OLD behaviour and that it will be removed in a future version.

In FreeCAD we switched to the new behaviour now and removed the SOURCE signature from add_custom_command which affects the macros
fc_copy_sources, fc_target_copy_resource and fc_target_copy_resource_flat and their usage.
It's not possible any more to add files to a target by using the macros. Now a file must be added to the target before using the macros.

This commit fixes it for Arch, Draft, OpenSCAD, Material, Plot and Ship
2018-08-20 11:47:39 +02:00
wmayer
ad22eb317e clean up cmake macros add new macro fc_target_copy_resource_flat 2018-08-19 22:54:33 +02:00
wmayer
5012668a40 move cmake policy CMP0050 to new style 2018-08-19 13:59:42 +02:00
wmayer
dff2d6074f fix broken generate_from_xml macro 2018-08-19 13:34:05 +02:00
Ryan Pavlik
b45a297428 Fix typo in FreeCadMacros.cmake 2018-08-11 17:39:15 +02:00
Ryan Pavlik
af12b35719 Add fc_target_copy_resource/fc_copy_sources build message
Includes optional verbosity param for tracking down "two rules for..."
ninja/etc warnings.
2018-08-11 17:39:13 +02:00
Ryan Pavlik
6cd4079a2d Clean up and fix generate_from_py and generate_from_xml CMake macros
Includes native-path-usage fixing like the previous commit.
2018-08-11 17:39:13 +02:00
Ryan Pavlik
e4b770ab5e Clean up and improve fc_copy_sources and fc_target_copy_resource CMake macros
The previous steps of TO_NATIVE_PATH followed by ABSOLUTE
is not meaningful or reliable: output of ABSOLUTE is always in
"cmake" path format, not native path format. Native path input to
CMake commands may not do what you want.
2018-08-11 17:39:13 +02:00
Ryan Pavlik
539dea85a2 Clean up and improve "COPY_IF_DIFFERENT" CMake macro 2018-08-11 17:39:12 +02:00
Markus Hovorka
4816c1c5af Honor CMAKE_INSTALL_RPATH in SET_BIN_DIR
set_target_properties used up until now in the SET_BIN_DIR macro sets
the INSTALL_RPATH property and discards whatever it contained before.
The INSTALL_RPATH target property is initialized with the cache variable
CMAKE_INSTALL_RPATH (possilbly given via the -D option of cmake). To
preserve this "default" value this commit replaced set_target_properties
with set_property(... APPEND ...).
2017-05-31 23:08:16 +02:00
Johannes Obermayr
06bb8d69eb Fix RPATHS for area-native and area libs on Linux. 2017-02-10 21:09:49 +01:00
wmayer
0b40e1eb2a + fix cmake issue caused by patch 2015-09-11 14:47:47 +02:00
Johannes Obermayr
9b90e1e14b libarea doesn't depend on parts from CMAKE_INSTALL_LIBDIR
Fixes:
 -- Installing: /home/abuild/rpmbuild/BUILDROOT/FreeCAD-0.15.99+git20150727.1925-1.1.x86_64/usr/lib64/FreeCAD/lib/area.so
 CMake Error at src/Mod/Path/libarea/cmake_install.cmake:53 (file):
   file RPATH_CHANGE could not write new RPATH:

     /usr/lib64/FreeCAD/lib

   to the file:

     /home/abuild/rpmbuild/BUILDROOT/FreeCAD-0.15.99+git20150727.1925-1.1.x86_64/usr/lib64/FreeCAD/lib/area.so

   No valid ELF RPATH or RUNPATH entry exists in the file;
2015-09-11 07:18:07 +02:00
wmayer
3a40a99742 + create MODULE libraries in given directory 2015-07-24 22:56:18 +02:00
wmayer
40883ac597 + use .dylib for normal shared libraries under MacOSX 2015-04-17 18:13:51 +02:00
Johannes Obermayr
dfa700a6a1 Fix OCE / OCC version detection. 2014-12-20 22:41:31 +01:00
wmayer
222bcf39c4 + improve OCC version macro, fix build failure with MinGW, fix build failure with Coin2 2014-08-18 11:34:02 +02:00
wmayer
e678de5f49 + Add macro to test and get OCC version 2014-08-10 18:52:28 +02:00
wmayer
6ac93e9d72 Add initial support for different libdir (jobermayr) 2014-05-10 12:57:38 +02:00
mdinger
1498e99cef Move python module prefix and suffix properties into macro to be set together 2014-05-03 16:00:30 +02:00
wmayer
2bb8a2d9a6 + fix PCH to work again with QtCreator 2014-04-30 19:04:32 +02:00
wmayer
e799982a80 + Fix PCH issue with VS 2014-04-30 14:07:27 +02:00
mdinger
f53989e7a6 Fix precompiled header build error 2014-04-30 13:41:19 +02:00