can cmake-js compile projects containing both c code and c++ code appropriately?
See original GitHub issueIssue Description
- I’m relatively new with C/C++.
I’m trying to make myself a native c++ addon which depends on the pigpio C Library intended for a Raspberry Pi.
The compilation fails, emitting lots of errors about the main pigpio.c file (written in C code) regarding things like implicit type casting, using the new
keyword as a variable name, and more…
Of course, theses errors show only when using cmake-js compile
on my whole addon project (which is based on c++ as mentioned); as opposed, trying to compile the pigpio library alone with gcc directly and no c++ code involved - succeeds flawlessly.
Is there a way to tell cmake-js/cmake to treat *.c
files as C code and compile them appropriately?
Or maybe I’m missing some point…?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
CMake: How to Build and Package C/C++ Projects - YouTube
In this workshop we will learn about CMake, a build generation tool used to build cross platform C /C++ projects. If you are...
Read more >How to properly link libraries with cmake? - Stack Overflow
My recommendation is to start simple, and then complicate your project further. Let me try to explain how linking works in CMake.
Read more >CMake Tutorial — CMake 3.19.8 Documentation
The CMake tutorial provides a step-by-step guide that covers common build system issues that CMake helps address. Seeing how various topics all work...
Read more >Getting Started With CMake - Earthly Blog
When it comes to packaging an application, there are many ways to do it. However, with languages that have been around as long...
Read more >@ajm/cmake-js NPM | npm.io
js module doesn't build your project, CMake does. All of its commands (configure, build, clean, etc.) are simple CMake invocations without involving JS...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Well, as you suggested, the lib author does provide a build script in the pigpio website. I was able to create a libpigpio.so file thanks to that, which I added to my project and to my cmake config:
target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB} pigpio)
I guess the best way should have been to set pigpio in my project with a nested CMakeLists.txt, but for now I’m happy because it works 😃
Thanks!
Glad to hear it. Then please close issue.