14. Example: firstlib
cmake_minimum_required (VERSION 2.6)
project(firstlib)
add_library(first STATIC firstlib.cpp)
install(TARGETS first
LIBRARY DESTINATION ${CMAKE_SOURCE_DIR}/lib
ARCHIVE DESTINATION ${CMAKE_SOURCE_DIR}/lib
)
install(FILES firstlib.h DESTINATION
${CMAKE_SOURCE_DIR}/include)
CMakeLists.txt in firstlib
#include "firstlib.h"
int add(int a, int b) {
return a+b;
}
firstlib.cpp in firstlib
#ifndef FIRSTLIB_H
#define FIRSTLIB_H
int add(int a, int b);
#endif //FIRSTLIB_H
firstlib.h in firstlib