Coder Social home page Coder Social logo

archicad-addon-cmake's Introduction

Archicad Add-On CMake Template

This repository contains a CMake template for Archicad Add-On Development.

Prerequisites

  • Development environment:
  • CMake (3.16 minimum version is needed).
  • Python for resource compilation and build script usage (3.8+).

Quick setup

The easiest way to generate projects and build the Add-On is to use the provided build script. The project and the binaries will be created in the Build folder.

  1. Open a command prompt.
  2. Clone this repository:
git clone https://github.com/GRAPHISOFT/archicad-addon-cmake.git --recurse-submodules
  1. Run the build script from the root of the repository:
python Tools/BuildAddOn.py --configFile config.json

Config file

The build script reads the config.json file for required build parameters:

  • addOnName: name of the Add-On.
  • defaultLanguage: a single language for which the Add-On is built when localization is not enabled.
  • languages: list of languages, for which localization can be done / for which the .grc files are present in their respective directories.
  • additionalCMakeParams (optional): a list of additional Add-On specific CMake parameters as JSON key-value pairs. The build script will forward it to CMake.

See the example config.json.

Detailed instructions

If the provided build script doesn't work for you, you can set up your environment manually.

Clone this repository

This repository uses archicad-addon-cmake-tools as a submodule, so in order to use this repository you need to be sure that all submodules are cloned properly.

To clone the repository with submodules, use the following command.

git clone https://github.com/GRAPHISOFT/archicad-addon-cmake.git --recurse-submodules

To get the latest changes together with submodule changes, use the following command.

git pull --recurse-submodules

To update only the submodules, use the following command.

git submodule update --remote

Build with downloaded Archicad API Development Kit

  • Clone this repository as it's described in the previous section.
  • Download the Archicad Add-On Development Kit from here or from here.
  • Generate the IDE project with CMake, and set the following variables (see example below):
    • AC_VERSION: The version number of Archicad that the Add-On is built for.
    • AC_API_DEVKIT_DIR: The Support folder of the installed Archicad Add-On Development Kit. You can also set an environment variable with the same name so you don't have to provide this value during project generation.
    • AC_ADDON_NAME: (optional) The name of the project file and the result binary Add-On file (default is "ExampleAddOn").
    • AC_ADDON_LANGUAGE: (optional) The language code of the Add-On (default is "INT").
  • To release your Add-On you need to provide valid MDIDs, you can generate them on the Archicad API site.

Visual Studio (Windows)

See the list below for the matching Visual Studio and platform toolset versions for different Archicad versions.

Archicad Visual Studio Platform toolset
Archicad 28 Visual Studio 2019 v142
Archicad 27 Visual Studio 2019 v142
Archicad 26 Visual Studio 2019 v142
Archicad 25 Visual Studio 2019 v142
Archicad 24 Visual Studio 2017 v141
Archicad 23 Visual Studio 2017 v141

Please note that you can always use the latest Visual Studio, but make sure you provide the correct platform toolset.

Example for using Visual Studio 2022 with platform toolset 142:

cmake -B Build -G "Visual Studio 17 2022" -A x64 -T v142 -DAC_API_DEVKIT_DIR=<DevKitSupportDir> -DAC_VERSION=28 .

XCode (MacOS)

See the list below for the matching deployment targets for different Archicad versions.

Archicad Deployment target
Archicad 28 11.0
Archicad 27 10.15
Archicad 26 10.15
Archicad 25 10.15
Archicad 24 10.13
Archicad 23 10.12

Run this command from the command line to generate the XCode project:

cmake -B Build -G "Xcode" -DAC_API_DEVKIT_DIR=<DevKitSupportDir> -DAC_VERSION=28 .

Visual Studio Code (Platform Independent)

  • Install the "CMake Tools" extension for Visual Studio Code.
  • Set the "AC_API_DEVKIT_DIR" environment variable to the installed Development Kit Support folder.
  • Open the root folder in Visual Studio Code, configure and build the solution.

Archicad Compatibility

This template is tested with all Archicad versions starting from Archicad 25.

Use in Archicad

To use the Add-On in Archicad, you have to add your compiled .apx or .bundle file in Add-On Manager. The example Add-On registers a new command into the Options menu. Please note that the example Add-On works only in the demo version of Archicad.

You can start Archicad in demo mode by the following command line commands:

  • Windows: ARCHICAD.exe -DEMO
  • MacOS: ARCHICAD\ 26.app/Contents/MacOS/ARCHICAD -demo

archicad-addon-cmake's People

Contributors

adimeny avatar asomorjai avatar bghszabi avatar butttcsu avatar dushyant-basson avatar esfarkas avatar imecsbulcsu avatar kissandras avatar kovacsv avatar lucienzhang avatar mkrisztiangraphi avatar tlorantfy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

archicad-addon-cmake's Issues

Some Add-on Examples need additional compiler options for Xcode 14.3.1 and AppleClang 14.0.3.14030022 on Apple Silicon

Thanks for the updated build scripts.

When using this script with Xcode 14.3.1 and AppleClang 14.0.3.14030022 on Apple Silicon to compile some of the Example Add-ons, additional compiler options are required.

There are a some warnings showing as errors when using the Geometry library. I added the following compile options:

-Wno-unknown-pragmas
-Wno-missing-braces
-Wno-unused-but-set-variable

How to make the developer ID and AddOn ID private but the 'GICN' resources public in a safe way?

'MDID' 32500 "Add-On Identifier" {

If I am working on public repository on Git I don't want commit the whole AddOnFix.grc file.
I was thinking about having a separate file like a mdidFix.grc(containing some private information) which would be ignored by git but still included in the AddOnFix.grc. When it builds I have to replace the two IDs manually only in the file which contains private information.
Is it possible to separate these things?

Wno-deprecated-copy compile option not found

While compiling i've got error:
error: unknown warning option '-Wno-deprecated-copy'; did you mean '-Wno-deprecated'? [-Werror,-Wunknown-warning-option]
Changing Wno-deprecated-copy to Wno-deprecated fixed the problem
Platform: MAC OSX 10.15
Devkit: 25_4000
Targeted Archicad 25
AppleClang 12.0.0.12000032

Resolving API name/type changes in different versions

Hello! Thanks for this template. It's been very useful to get started on a plugin.

I started with this template, then have copied in most of the BrowserControl example. I noticed when doing this that the builds started failing for Archicad 25 and 26. This appears to be for a few reasons, but all of them seem to be namespace or function name changes.

For example, ACAPI_Register_Menu in AC26 vs. ACAPI_MenuItem_RegisterMenu in AC27.
Similarly, the JS object classes were formerly DG::JSValue and are now JS::Value.

I am relatively new to C++. Is there a technique for using different names based on AC version? It would be convenient to be able to target multiple out of one project.

Coming from C# the equivalent would be:

#if ARCHICAD_26
using JSValue = DG.JSValue;
#else
using JSValue = JS.Value
#endif

Edit: Looking at this again it seems like quite a bit of work to manage multiple versions as the API seems to have changed a reasonable amount (at least by naming convention) between AC26 and AC27

Adding APICommon.c file to the project causes build issue

The official API Development Kit contains the APICommon.c file which is an utility set with useful functions.
I need those so I added that file into the template project, then I received the following compiler issues:

    APICommon.c
D:\Program Files\GRAPHISOFT\API Development Kit 25.3004\Support\Modules\GSRoot\Win32Interface.hpp(197,11): error C2143: syntax error: missing '{' before '<' [D:\Program Files\GRAPHISOFT\API Development Kit 25.3004\Examples\archicad-addon-cmake-master\build\AddOn.vcxproj]
D:\Program Files\GRAPHISOFT\API Development Kit 25.3004\Support\Modules\GSRoot\Win32Interface.hpp(197,11): error C2059: syntax error: '<' [D:\Program Files\GRAPHISOFT\API Development Kit 25.3004\Examples\archicad-addon-cmake-master\build\AddOn.vcxproj]
D:\Program Files\GRAPHISOFT\API Development Kit 25.3004\Support\Modules\GSRoot\Win32Interface.hpp(202,11): error C2143: syntax error: missing '{' before '<' [D:\Program Files\GRAPHISOFT\API Development Kit 25.3004\Examples\archicad-addon-cmake-master\build\AddOn.vcxproj]
D:\Program Files\GRAPHISOFT\API Development Kit 25.3004\Support\Modules\GSRoot\Win32Interface.hpp(202,11): error C2059: syntax error: '<' [D:\Program Files\GRAPHISOFT\API Development Kit 25.3004\Examples\archicad-addon-cmake-master\build\AddOn.vcxproj]
D:\Program Files\GRAPHISOFT\API Development Kit 25.3004\Support\Modules\GSRoot\Win32Interface.hpp(407,14): error C2084: function 'BOOL DrawText(HDC,LPCSTR,int,LPRECT,UINT)' already has a body [D:\Program Files\GRAPHISOFT\API Development Kit 25.3004\Examples\archicad-addon-cmake-master\build\AddOn.vcxproj]
D:\Program Files\GRAPHISOFT\API Development Kit 25.3004\Support\Modules\GSRoot\Win32Interface.hpp(402): message : see previous definition of 'DrawText' [D:\Program Files\GRAPHISOFT\API Development Kit 25.3004\Examples\archicad-addon-cmake-master\build\AddOn.vcxproj]
D:\Program Files\GRAPHISOFT\API Development Kit 25.3004\Support\Modules\GSRoot\GSRoot.hpp(19,1): fatal error C1189: #error: 	GSRoot.hpp can be included only in CPP files ! [D:\Program Files\GRAPHISOFT\API Development Kit 25.3004\Examples\archicad-addon-cmake-master\build\AddOn.vcxproj]

Failed to detect Archicad version, please check the value of the AC_API_DEVKIT_DIR variable

I tried to follow the steps from here https://archicadapi.graphisoft.com/getting-started-with-archicad-add-ons, but I get an error when I try to run this command.

cmake -G "Visual Studio 17 2022" -A "x64" -DAC_API_DEVKIT_DIR="C:\Program Files\GRAPHISOFT\API Development Kit 26.3000" ..
CMake Error at CMakeLists.txt:59 (message):
  Failed to detect Archicad version, please check the value of the
  AC_API_DEVKIT_DIR variable.
-- Configuring incomplete, errors occurred!

I have installed the API Dev Kit 26.3000 under the provided Path.

GitHub Actions doesn't work, cmake doesn't build with conan

Hi,
I forked the repo and tried to build it with conan on my Mac, but faced some difficulties. I'm new to C++, it would be great if you could help.

  1. I try to run GitHub Action in my forked repo, but it fails
    my run is here, the only change I made is here
  2. I tried to build the project with conan, but seems cmake failed reading AC_API_DEVKIT_DIR.

My environment

MacOS=13.2.1
Python=3.10.8
cmake version 3.25.2
Conan version 1.59.0

Log

$ conan install . -pr:b=default --install-folder=Build/
Configuration (profile_host):
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=apple-clang
compiler.libcxx=libc++
compiler.version=13
os=Macos
os_build=Macos
[options]
[build_requires]
[env]

Configuration (profile_build):
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=apple-clang
compiler.libcxx=libc++
compiler.version=13
os=Macos
os_build=Macos
[options]
[build_requires]
[env]

archicad-apidevkit/26: Main binary package '4b92821f1af51ada4198018b78c8b197b32c6c18' missing. Using compatible package '2cd20192e71f56e1115fbdc2ebf2871bb61152e4'
conanfile.py: Installing package
Requirements
    archicad-apidevkit/26 from 'conancenter' - Cache
Packages
    archicad-apidevkit/26:2cd20192e71f56e1115fbdc2ebf2871bb61152e4 - Cache

Installing (downloading, building) binaries...
archicad-apidevkit/26: Already installed!
archicad-apidevkit/26: Setting AC_API_DEVKIT_DIR environment variable: /Users/lucien/.conan/data/archicad-apidevkit/26/_/_/package/2cd20192e71f56e1115fbdc2ebf2871bb61152e4/bin
conanfile.py: Generator 'CMakeToolchain' calling 'generate()'
conanfile.py: Preset 'release' added to CMakePresets.json. Invoke it manually using 'cmake --preset release'
conanfile.py: If your CMake version is not compatible with CMakePresets (<3.19) call cmake like: 'cmake <path> -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=/Users/lucien/Projects/compliance_helper/conan/conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release'
conanfile.py: Generator 'CMakeDeps' calling 'generate()'
conanfile.py: Generator cmake_paths created conan_paths.cmake
conanfile.py: Generator txt created conanbuildinfo.txt
conanfile.py: Generator 'VirtualBuildEnv' calling 'generate()'
conanfile.py: Aggregating env generators
conanfile.py: Generated conaninfo.txt
conanfile.py: Generated graphinfo
$ cd Build && cmake -G "Xcode" ..
CMake Error at CMakeLists.txt:57 (message):
  Failed to detect Archicad version, please check the value of the
  AC_API_DEVKIT_DIR variable.


-- Configuring incomplete, errors occurred!
$ grep "export AC_API_DEVKIT_DIR" ./conan/conanbuildenv-release-x86_64.sh
export AC_API_DEVKIT_DIR="/Users/lucien/.conan/data/archicad-apidevkit/26/_/_/package/2cd20192e71f56e1115fbdc2ebf2871bb61152e4/bin"

$ grep "AC_API_DEVKIT_DIR" ./Build/CMakeCache.txt
AC_API_DEVKIT_DIR:PATH=

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.