Last active
January 16, 2019 23:42
-
-
Save hazelement/b9d65db77e1f8e3fd56d99f05661d0f2 to your computer and use it in GitHub Desktop.
Cmake Examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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