Q: How to add cmake project to another cmake project as library? I have been researching over hours but I still couldn't solve my problem.
This is Cmakelist of ProjectA. It perfectly works: 
cmake_minimum_required(VERSION 3.5)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
project(ProjectA C CXX)
add_executable(ProjectA ${SOURCE_FILES_ProjectA})
target_link_libraries(ProjectA hts ${ZLIB} pthread)
target_compile_definitions(ProjectA PUBLIC -D_FILE_OFFSET_BITS=64 -DVERSION=\"${VERSION_STRING}\")

Now I want to add ProjectA to ProjectB as library but I got following error at first:

add_executable cannot create target "ProjectA" because another
    target with the same name already exists.  The existing target is a static
    library created in source directory

Then, I changes cmakelist of projectB as below. Now makefile is created but it doesn't work. (I removed set(source_files) for simplicity)
ProjectB cmakelist:
include_directories(
${PROJECT_SOURCE_DIR}/lib
${PROJECT_SOURCE_DIR}/
${PROJECT_SOURCE_DIR}/lib/ProjectA)
add_library(ProjectA STATIC lib/ProjectA/src})
target_include_directories(ProjectA PUBLIC lib/ProjectA)
set_target_properties(ProjectA PROPERTIES LINKER_LANGUAGE CXX)

add_executable(ProjectB ${SOURCE_FILES})
target_link_libraries(ProjectB hts ${ZLIB} ProjectA pthread)
target_compile_definitions(ProjectB PUBLIC -D_FILE_OFFSET_BITS=64 -DVERSION=\"${VERSION_STRING}\")

Can you correct my cmakelist files, I am really lost in cmake syntax.
