Discussion:
[CMake] CMAKE_EXPORT_COMPILE_COMMANDS don't work in CMakeLists.txt
Fabrício Ceolin
2016-12-05 11:31:46 UTC
Permalink
Hi,

I am trying to put
set(CMAKE_EXPORT_COMPILE_COMMANDS ,1) inside a toolchain file but the
command has no effect there. I've tried to put it in CMakeLists.txt too
using the previosly set and
add_definitions(-DCMAKE_EXPORT_COMPILE_COMMANDS=1) without success.

The command only works in command line, when I put
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 in cmake args.

I am using ubuntu 16.04 with cmake 3.5.1 from ubuntu (3.5.1-1ubuntu1).

Is it possible to use CMAKE_EXPORT_COMPILE_COMMANDS inside external
toolchain file (using args -DCMAKE_TOOLCHAIN_FILE=<filename>.cmake) or in
CMakeLists.txt?

Thanks,


Fabrício Ceolin
+55 (31) 98675-1359
MiningMath Associates
www.miningmath.com
Wagner, David
2016-12-07 10:13:50 UTC
Permalink
Post by Fabrício Ceolin
Hi,
I am trying to put
set(CMAKE_EXPORT_COMPILE_COMMANDS ,1) inside a toolchain file but the command
has no effect there. I've tried to put it in CMakeLists.txt too using the
previosly set and add_definitions(-DCMAKE_EXPORT_COMPILE_COMMANDS=1) without
success.
"set(CMAKE_EXPORT_COMPILE_COMMANDS 1)" inside the CMakeLists.txt works for me
but note that you have an extra comma before the "1" value. CMake only uses
commas for lists. It probably also works in the toolchain file. I don't see how
using add_definitions() would work because it is only used in the compiler's
command line.

W
--
David Wagner

complex != complicated
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number: 302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
--
Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Fabrício Ceolin
2016-12-07 10:35:07 UTC
Permalink
Hi,

Thank you David. Which version of cmake and operational system are you
using?
In my CMakeLists.txt file, I tried to set

set(CMAKE_EXPORT_COMPILE_COMMANDS 1)

and

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

without success, unfortunately.
Post by Fabrício Ceolin
Post by Fabrício Ceolin
Hi,
I am trying to put
set(CMAKE_EXPORT_COMPILE_COMMANDS ,1) inside a toolchain file but the
command
Post by Fabrício Ceolin
has no effect there. I've tried to put it in CMakeLists.txt too using the
previosly set and add_definitions(-DCMAKE_EXPORT_COMPILE_COMMANDS=1)
without
Post by Fabrício Ceolin
success.
"set(CMAKE_EXPORT_COMPILE_COMMANDS 1)" inside the CMakeLists.txt works for me
but note that you have an extra comma before the "1" value. CMake only uses
commas for lists. It probably also works in the toolchain file. I don't see how
using add_definitions() would work because it is only used in the compiler's
command line.
W
--
David Wagner
complex != complicated
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number: 302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
--
Powered by www.kitware.com
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at http://www.kitware.com/
opensource/opensource.html
http://public.kitware.com/mailman/listinfo/cmake
Wagner, David
2016-12-07 10:48:18 UTC
Permalink
I've tested this on Ubuntu 15.10 using CMake 3.2.2

Where, in the CMakeLists did you put it? As far as I can tell, it needs to be
done before defining the targets for which you want compile commands to be exported.

W
Hi,
Thank you David. Which version of cmake and operational system are you using?
In my CMakeLists.txt file, I tried to set
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
and
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
without success, unfortunately.
Post by Fabrício Ceolin
Hi,
I am trying to put
set(CMAKE_EXPORT_COMPILE_COMMANDS ,1) inside a toolchain file but the command
has no effect there. I've tried to put it in CMakeLists.txt too using the
previosly set and add_definitions(-DCMAKE_EXPORT_COMPILE_COMMANDS=1) without
success.
"set(CMAKE_EXPORT_COMPILE_COMMANDS 1)" inside the CMakeLists.txt works for me
but note that you have an extra comma before the "1" value. CMake only uses
commas for lists. It probably also works in the toolchain file. I don't see how
using add_definitions() would work because it is only used in the compiler's
command line.
W
--
David Wagner
complex != complicated
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number: 302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
--
Powered by www.kitware.com <http://www.kitware.com>
http://www.cmake.org/Wiki/CMake_FAQ <http://www.cmake.org/Wiki/CMake_FAQ>
Kitware offers various services to support the CMake community. For more
CMake Support: http://cmake.org/cmake/help/support.html
<http://cmake.org/cmake/help/support.html>
CMake Consulting: http://cmake.org/cmake/help/consulting.html
<http://cmake.org/cmake/help/consulting.html>
CMake Training Courses: http://cmake.org/cmake/help/training.html
<http://cmake.org/cmake/help/training.html>
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
<http://www.kitware.com/opensource/opensource.html>
http://public.kitware.com/mailman/listinfo/cmake
<http://public.kitware.com/mailman/listinfo/cmake>
--
David Wagner

complex != complicated
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number: 302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
--
Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
Fabrício Ceolin
2016-12-07 16:16:44 UTC
Permalink
Putting

set(CMAKE_EXPORT_COMPILE_COMMANDS 1)

right above defining target solve the problem.


Fabrício Ceolin
+55 (31) 98675-1359
MiningMath Associates
www.miningmath.com
Post by Wagner, David
I've tested this on Ubuntu 15.10 using CMake 3.2.2
Where, in the CMakeLists did you put it? As far as I can tell, it needs to
be done before defining the targets for which you want compile commands to
be exported.
W
Hi,
Thank you David. Which version of cmake and operational system are you using?
In my CMakeLists.txt file, I tried to set
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
and
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
without success, unfortunately.
Post by Fabrício Ceolin
Hi,
I am trying to put
set(CMAKE_EXPORT_COMPILE_COMMANDS ,1) inside a toolchain file but
the command
Post by Fabrício Ceolin
has no effect there. I've tried to put it in CMakeLists.txt too
using the
Post by Fabrício Ceolin
previosly set and add_definitions(-DCMAKE_EXPORT_COMPILE_COMMANDS=1)
without
Post by Fabrício Ceolin
success.
"set(CMAKE_EXPORT_COMPILE_COMMANDS 1)" inside the CMakeLists.txt works for me
but note that you have an extra comma before the "1" value. CMake only uses
commas for lists. It probably also works in the toolchain file. I don't see how
using add_definitions() would work because it is only used in the compiler's
command line.
W
--
David Wagner
complex != complicated
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number: 302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
--
Powered by www.kitware.com <http://www.kitware.com>
http://www.cmake.org/Wiki/CMake_FAQ <http://www.cmake.org/Wiki/CMa
ke_FAQ>
Kitware offers various services to support the CMake community. For more
CMake Support: http://cmake.org/cmake/help/support.html
<http://cmake.org/cmake/help/support.html>
CMake Consulting: http://cmake.org/cmake/help/consulting.html
<http://cmake.org/cmake/help/consulting.html>
CMake Training Courses: http://cmake.org/cmake/help/training.html
<http://cmake.org/cmake/help/training.html>
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
<http://www.kitware.com/opensource/opensource.html>
http://public.kitware.com/mailman/listinfo/cmake
<http://public.kitware.com/mailman/listinfo/cmake>
--
David Wagner
complex != complicated
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 92196 Meudon
Cedex, France
Registration Number: 302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
Loading...