file(GLOB SRC_FILES "*.cpp") foreach(SRC_FILE ${SRC_FILES}) get_filename_component(EXE_NAME ${SRC_FILE} NAME_WE) add_executable(${EXE_NAME} ${SRC_FILE}) target_link_libraries(${EXE_NAME} gtest gmock) endforeach()