cmake_minimum_required (VERSION 2.8) set(lib_name hello_ci_world) project (${lib_name}) file(GLOB SRC "src/*.c" "src/*.cpp" ) LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib) # static Library Output add_library(${lib_name} STATIC ${SRC}) set_target_properties(${lib_name} PROPERTIES OUTPUT_NAME ${lib_name}) add_executable(test_hello_ci_world test/test.c) target_link_libraries(test_hello_ci_world ${lib_name}) set(CMAKE_INSTALL_RPATH ${CMAKE_SOURCE_DIR}/lib) SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) #install(TARGETS ${lib_name} LIBRARY DESTINATION ${CMAKE_SOURCE_DIR}/lib) install(TARGETS test_hello_ci_world DESTINATION ${CMAKE_SOURCE_DIR}/test)