c++ - How to make object file with different command and .exe with different command in cmake -


i know how generate object file different g++ command ex:

  • g++ -pipe -d__gnuwin32__ -c main.cpp -o main.o

and using main.o file need generate .exe file different command ex

  • g++ -mwindows main.o -o main.exe how ...

you should try object library target , set_target_properties command.

the object library enables create target , compile object files without linking.

the set_target_properties command enables, among others, add specific flags target.

here's small example using question :

add_library(main_object object main.cpp) set_target_properties(main_object properties compile_flags "-pipe -d__gnuwin32__") add_executable(main $<target_objects:main_object>) set_target_properties(main properties link_flags "-mwindows") 

Comments