Skip to content

Instantly share code, notes, and snippets.

@jbruchanov
Created March 22, 2017 11:39
Show Gist options
  • Save jbruchanov/cf065419657a3e5c366582866ea47249 to your computer and use it in GitHub Desktop.
Save jbruchanov/cf065419657a3e5c366582866ea47249 to your computer and use it in GitHub Desktop.
CMake
cmake_minimum_required(VERSION 3.6)
project(SampleProject)
#enable C++ 11
set(CMAKE_CXX_STANDARD 11)
#seems like include libgcc library (didn't work everytime)
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
#header file location
include_directories("c:\\Temp\\header")
#region .so
link_directories( c:\\Temp\\header ) #libSample2.dll
set(SOURCE_FILES main.cpp)
add_executable(SampleProject ${SOURCE_FILES})
target_link_libraries(SampleProject Sample2)#'libSample2.dll' becomes to 'Sample2'
#endregion .so
#region .a
include_directories("c:\\Temp\\header")
find_library(PROJECT_LINK_LIBS libSample2.a PATHS c:/Temp/header/lib)
message(${PROJECT_LINK_LIBS})#=>C:/Temp/header/lib/libSample2.a
set(SOURCE_FILES main.cpp)
add_executable(SampleProject ${SOURCE_FILES})
target_link_libraries(SampleProject ${PROJECT_LINK_LIBS})
#endregion .a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment