My opject using cmake, some compile options is configured by set
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DMY_MACRO_DEBUG")
...
set(CMAKE_CXX_FLAGS_RELEASE "-g")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DMY_MACRO_RELEASE")
...
and some compile options is configured by add_definitions()
add_definitions(-DMY_MACRO_1)
add_definitions(-DMY_MACRO_2)
...
after finish the configure, I want print all compile options using message
I want something output like follow
Compile options in debug mode: -g -O0 -Wall -DMY_MACRO_DEBUG -DMY_MACRO_1 -DMY_MACRO_2
Compile options in release mode: -g -O3 -Wall -DMY_MACRO_RELEASE -DMY_MACRO_1 -DMY_MACRO_2
How can I implement that? Thanks for your time.
Appendix 1
I know using make VERBOSE=1
can show the information, but it can only show debug options using debug mode, show release options using release mode. It can not show all mode's options at same time. Furthermore, it also include too many -I /path1 -I /path2
. It is not a comfortable way to read that.
I want the information be display after we type cmake ..
Appendix 2
If -DMY_MACRO_1 -DMY_MACRO_2
can be print by some cmake variable something like ${CMAKE_ALREADY_ADD_DEFINITIONS}
.
message(${CMAKE_ALREADY_ADD_DEFINITIONS})
the problem can be easy settled. But I don know if there exist a varible like that.