[Insight-users] Fwd: C++ Win32 DLL Application

John Drescher drescherjm at gmail.com
Sat Nov 24 15:33:34 EST 2012


On Sat, Nov 24, 2012 at 3:23 PM, Sam <sistephan at gmail.com> wrote:
> Ok, can I do this:
>
> Create a blank .h/.cpp file.  Use CMAKE like this to create a Win 32 DLL
> Application.  Then open the .sln file and add implementation details to my
> .h/.cpp files and build it?
>
> # This is the root ITK CMakeLists file.
> cmake_minimum_required(VERSION 2.4)
> if(COMMAND CMAKE_POLICY)
>   cmake_policy(SET CMP0003 NEW)
> endif(COMMAND CMAKE_POLICY)
>
>
> # This project is designed to be built outside the Insight source tree.
> project(MyITKProject)
>
> # Find ITK.
> find_package(ITK REQUIRED)
> include(${ITK_USE_FILE})
>
> #This includes my blank .h/.cpp file?
> INCLUDE_DIRECTORIES(C:\MySourceDirectory)

Use the following instead of the above:
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})

>

You add your .cxx .cpp .h files after the SHARED in the following line:
> add_library(MyITKProject SHARED)
>
> target_link_libraries(HelloWorld ${ITK_LIBRARIES})

Maybe you want
target_link_libraries(MyITKProject ${ITK_LIBRARIES})

Although eventually I expect you to also build a .exe from the
CMakeLists.txt to at least test the .dll you are building.

John


More information about the Insight-users mailing list