CMakeLists.txt 723 B

12345678910111213141516171819
  1. project(ConvLibrary)
  2. # create a source list
  3. set(foo_sources foo.cxx bar.c sub1/car.cxx)
  4. # create a library foo from the sources
  5. add_library(foo ${foo_sources})
  6. # get the object files from the target
  7. get_target_property(OBJECT_FILES foo OBJECT_FILES)
  8. message("${OBJECT_FILES}")
  9. # set the object files as generated
  10. set_source_files_properties(${OBJECT_FILES} PROPERTIES GENERATED true)
  11. # create a library bar that contains the object files from foo
  12. add_library(bar ${OBJECT_FILES})
  13. # set the linker language since bar only has .obj
  14. set_target_properties(bar PROPERTIES LINKER_LANGUAGE CXX)
  15. # make sure foo is built before bar
  16. add_dependencies(bar foo)
  17. add_executable(bartest bartest.cxx)
  18. target_link_libraries(bartest bar)