Skip to content

Instantly share code, notes, and snippets.

@hazelement
Last active January 16, 2019 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hazelement/b9d65db77e1f8e3fd56d99f05661d0f2 to your computer and use it in GitHub Desktop.
Save hazelement/b9d65db77e1f8e3fd56d99f05661d0f2 to your computer and use it in GitHub Desktop.
Cmake Examples
cmake_minimum_required(VERSION 2.8.9)
project (TestLibrary)
#For the shared library:
set ( PROJECT_LINK_LIBS libtestStudent.so )
link_directories( ~/exploringBB/extras/cmake/studentlib_shared/build )
#For the static library:
#set ( PROJECT_LINK_LIBS libtestStudent.a )
#link_directories( ~/exploringBB/extras/cmake/studentlib_static/build )
include_directories(~/exploringBB/extras/cmake/studentlib_shared/include)
add_executable(libtest libtest.cpp)
target_link_libraries(libtest ${PROJECT_LINK_LIBS} )
cmake_minimum_required(VERSION 2.8.9)
project(directory_test)
set(CMAKE_BUILD_TYPE Release)
#Bring the headers, such as Student.h into the project
include_directories(include)
#However, the file(GLOB...) allows for wildcard additions:
file(GLOB SOURCES "src/*.cpp")
#Generate the shared library from the sources
add_library(testStudent SHARED ${SOURCES})
#Generate the static library from the sources
# add_library(testStudent STATIC ${SOURCES})
#Set the location for library installation -- i.e., /usr/lib in this case
# not really necessary in this example. Use "sudo make install" to apply
install(TARGETS testStudent DESTINATION /usr/lib)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment