This is a very trivial problem and may be due to my inexperience with CMake. I have followed the tutorial at http://fabzter.com/blog/cmake-tutorial-1 and am having issues with linking.
Basically I have a library MathFuncs and an executable that uses MathFuncs. The CMakeLists for MathFuncs is:
cmake_minimum_required(VERSION 2.8)
project(MathFuncs)
include_directories(${PROJECT_SOURCE_DIR})
SET (HEADER_FILES mysqrt.hpp)
add_library(MathFuncs SHARED mysqrt.cpp ${HEADER_FILES})
and the executable CMakeLists is:
cmake_minimum_required (VERSION 2.6)
project (Tutorial)
set (Tutorial_VERSION_MAJOR 1)
set (Tutorial_VERSION_MINOR 0)
set (Tutorial_VERSION_BUGFIX 0)
#configure header file to pass some of the CMake settings
#to the source code
configure_file(
"${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
"${PROJECT_BINARY_DIR}/TutorialConfig.h"
)
# add the binary tree to the search path for include files
# so that we will find TutorialConfig.h
include_directories("${PROJECT_BINARY_DIR}")
# add the include directories necessary to build library
include_directories("${PROJECT_SOURCE_DIR}/MathFuncs}")
add_subdirectory(MathFuncs)
SET (MATHFUNCTIONS_DIR ${PROJECT_SOURCE_DIR}/MathFuncs)
add_executable(tutorial tutorial.cpp ${MATHFUNCTIONS_DIR}/mysqrt.hpp)
target_link_libraries(tutorial MathFuncs)
CMake runs fine. However when I try to compile with Visual Studio, I get a linker error stating that it cannot open MathFuncs.lib. When I remove the 'SHARED' option from the MathFuncs CMakeList it runs since it is building a static library, however for my application I want a shared library DLL.
How do I make CMake set the library reference as shared?
Thank you,