CMakeLists.txt 760 B

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