Showing posts with label cmake. Show all posts
Showing posts with label cmake. Show all posts

Wednesday, July 3, 2013

Making 64-bit installers with CMake and NSIS

I was getting tired of my 64-bit programs getting installed by NSIS into the x86 folder under windows, just because the NSIS installer itself is 32-bit.

I started piecing the solution together from this bug report for CMake. NSIS has been ported to 64bit but the inclusion in CMake is only available in the latest release. So I had to get NSIS 64,  and latest version of CMake 2.8.11 and then make some modifications to CPack to enable the new 64-bit installer.


Change installer type to NSIS64: SET(CPACK_GENERATOR NSIS64) and re-package your application. Voila you get correct program file target location and here is a screenshot of the running application just for fun.
Some products such as PCL do a platform detection while building to suggest an install folder, using the snippet below. This method will also work if you don't feel like installing NSIS64.

if(CMAKE_CL_64)
    set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
    set(win_system_name win64)
 else(CMAKE_CL_64)
    set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES32")
    set(win_system_name win32)
 endif(CMAKE_CL_64)

Tuesday, October 30, 2012

Trivial CMAKE for OpenSceneGraph

It is often fun to get open source projects working with Visual Studio since a lot of build systems leave out a few Microsoft specific vagaries. With CMAKE life in the last few years has become much easier, though sometimes it requires a bit of digging to locate the right incantations to pull in the right dependencies for a trivial project.

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(AeroViewer)

SET(TARGET_SRC aeroviewer.cpp )

find_package(OpenSceneGraph REQUIRED osgDB osgUtil osgGA osgViewer osgText)

ADD_EXECUTABLE(aeroviewer ${TARGET_SRC})

INCLUDE_DIRECTORIES(${OPENSCENEGRAPH_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(aeroviewer ${OPENSCENEGRAPH_LIBRARIES})  


The aim of this quick dash is to add a screen overlay with the company logo to the default osgViewer. This requires adding a geometry node to the scene with some static geometry in camera space. Which ends up being equivalent to a HUD in osg parlance. After a bit of tweaking and rotations in texture space I got this, not too bad for a cold-start in OSG land. This bit of sample code is better for HUD's than the tutorial, the required projection and modelview matrices are encapsulated by the CameraNode.