title: CMake to give (.o) file as output
body: <p>I'm trying to get mu C++ code to compile as object file (.o) but I can get it in (.a, .dylib, executable) forms</p>
  
  <p>I've tried this answer: <a href="https://stackoverflow.com/questions/51988350/copy-out-plain-o-files-with-cmake">Copy out plain .o files with cmake</a></p>
  
  <p>but didn't actually understood the solution and it didn't work either.</p>
  
  <p>how can I achieve this ?</p>
  
  <p>here is my CMake file:</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.10)
  
  project(myProject)
  
  set(CMAKE_CXX_STANDARD 14)
  set(CMAKE_CXX_STANDARD_REQUIRED True)
  set(LIBS_DIR ${PROJECT_SOURCE_DIR}/../libs)
  
  file(GLOB SOURCES
              src/*.cpp
              )
  
  find_library(SQLITE3
               NAMES libsqlite3.0.tbd
               )
  
  MACRO(HEADER_DIRECTORIES return_list)
      FILE(GLOB_RECURSE new_list ${LIBS_DIR}/*.h*)
      SET(dir_list "")
      FOREACH(file_path ${new_list})
          GET_FILENAME_COMPONENT(dir_path ${file_path} PATH)
          SET(dir_list ${dir_list} ${dir_path})
      ENDFOREACH()
      LIST(REMOVE_DUPLICATES dir_list)
      SET(${return_list} ${dir_list})
  ENDMACRO()
  
  add_library(${PROJECT_NAME}_obj OBJECT ${SOURCES})
  
  
  HEADER_DIRECTORIES(HDR_DIRS)
  
  target_include_directories(${PROJECT_NAME}_obj PUBLIC
                             ${PROJECT_BINARY_DIR}
                             ${PROJECT_SOURCE_DIR}/include
                             ${PROJECT_SOURCE_DIR}/../fmt
                             ${PROJECT_SOURCE_DIR}/../include
                             ${HDR_DIRS}
                             )
  
  target_link_libraries(${PROJECT_NAME}_obj ${SQLITE3})
  
  
  </code></pre>