[CMake] CPack and NSIS failure

David Demelier demelier.david at gmail.com
Wed Jun 27 06:24:51 EDT 2012


Hello,

I try to use CPack to create a Windows package using NSIS, it fails with:

[100%] Built target sd-tris
Run CPack packaging tool...
CPack: Create package using NSIS
CPack: Install projects
CPack: - Run preinstall target for: sd-tris
CPack: - Install project: sd-tris
CPack: Create package
CPack Error: Problem running NSIS command: "C:/Program Files
(x86)/NSIS/makensis.exe"
"C:/Users/markand/Documents/sd-tris/_build_/_CPack_Packages/win32/NSIS/project.nsi"
Please check C:/Users/markand/Documents/sd-tris/_build_/_CPack_Packages/win32/NSIS/NSISOutput.log
for errors
CPack Error: Problem compressing the directory
CPack Error: Error when generating package: sd-tris
mingw32-make: *** [package] Error 1

And the NSISOutput.log tail:

Section: "-Core installation"
SetOutPath: "$INSTDIR"
File: Returning to:
"C:/Users/markand/Documents/sd-tris/_build_/_CPack_Packages/win32/NSIS/sd-tris-0.1.1-win32"
File: "C:/Users/markand/Documents/sd-tris/_build_/_CPack_Packages/win32/NSIS/sd-tris-0.1.1-win32\*.*"
-> no files found.
Usage: File [/nonfatal] [/a] ([/r] [/x filespec [...]] filespec [...] |

   /oname=outfile one_file_only)

Error in script
"C:/Users/markand/Documents/sd-tris/_build_/_CPack_Packages/win32/NSIS/project.nsi"
on line 640 -- aborting creation process

There is no files under
C:/Users/markand/Documents/sd-tris/_build_/_CPack_Packages/win32/NSIS/sd-tris-0.1.1-win32,
that's probably why it fails to build.

I've attached the CMakeLists.txt,

Cheers,

-- 
Demelier David
-------------- next part --------------
#
# CMakeLists.txt -- CMake build system for sd-tris
#

# ---------------------------------------------------------
# General CMake parameters
# ---------------------------------------------------------

# General settings.
cmake_minimum_required(VERSION 2.8)
project(sd-tris C)

# CMake modules.
include(CheckFunctionExists)
include(CheckIncludeFile)

# Global variables.
set(CMAKE_MODULE_PATH "${sd-tris_SOURCE_DIR}/cmake")
set(PREFIX "${CMAKE_INSTALL_PREFIX}")
set(ROOTDIR "${sd-tris_SOURCE_DIR}")
set(BINARYDIR "${sd-tris_BINARY_DIR}")
set(EXTERNDIR "${sd-tris_SOURCE_DIR}/extern")

# Users for unix.
set(USER "games")
set(GROUP "games")

if (WIN32)
	set(PATH_INSTALL_BIN "${PREFIX}")
	set(PATH_INSTALL_NLS "${PREFIX}/lang")
	set(PATH_INSTALL_DATA "${PREFIX}")
else ()
	set(PATH_INSTALL_BIN "${PREFIX}/bin")
	set(PATH_INSTALL_NLS "${PREFIX}/share/locale")
	set(PATH_INSTALL_DATA "${PREFIX}/share/sdtris")

	set(PATH_INSTALL_SCORE "/var/db/sdtris")
endif ()

# Options
option(NLS "Enable native language support" On)

find_package(Wing REQUIRED)

#
# Enable NLS, if the library is not found the game won't link against it.
#
if (NLS)
	find_package(NLS)

	# If NLS is usable and found, link against it.
	if (NLS_FOUND)
		set(HAVE_NLS "1" CACHE INTERNAL "Use of NLS" FORCE)

		list(APPEND INCLUDES "${NLS_INCLUDE_DIR}")
		list(APPEND LIBRARIES "${NLS_LIBRARY}")
	endif ()
endif ()

# Create a make uninstall target.
configure_file(
	"${CMAKE_CURRENT_SOURCE_DIR}/cmake/uninstall.cmake.in"
	"${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake"
	IMMEDIATE @ONLY
)

add_custom_target(
	uninstall
	"${CMAKE_COMMAND}" -P
	"${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake"
)

# ---------------------------------------------------------
# Check of function, headers and so on
# ---------------------------------------------------------

# Check of asprintf(3) function.
check_function_exists(asprintf HAVE_ASPRINTF)
if (NOT HAVE_ASPRINTF)
	include_directories("${EXTERNDIR}/asprintf")
	list(APPEND EXTSOURCES "${EXTERNDIR}/asprintf/asprintf.c")
endif ()

# Check of err(3) functions.
check_function_exists(err HAVE_ERR)
if (NOT HAVE_ERR)
	include_directories("${EXTERNDIR}/err")
	list(APPEND EXTSOURCES "${EXTERNDIR}/err/err.c")
endif ()

# Check of getopt(3) function.
check_function_exists(getopt HAVE_GETOPT)
if (NOT HAVE_GETOPT)
	include_directories("${EXTERNDIR}/getopt")
	list(APPEND EXTSOURCES "${EXTERNDIR}/getopt/getopt.c")
endif ()

# Check of setprogname(3) function.
check_function_exists(setprogname HAVE_SETPROGNAME)
if (NOT HAVE_SETPROGNAME)
	include_directories("${EXTERNDIR}/setprogname")
	list(APPEND EXTSOURCES "${EXTERNDIR}/setprogname/setprogname.c")
endif ()

# random(3) is said to be better.
check_function_exists(random HAVE_RANDOM)

# c99 stdbool.h is still not supported on some platforms.
check_include_file(stdbool.h HAVE_STDBOOL)
if (NOT HAVE_STDBOOL)
	include_directories("${EXTERNDIR}/stdbool")
endif ()

# We always use _FOREACH_SAFE.
find_package(SysQueue)
if (NOT SYSQUEUE_FOUND
    OR NOT SYSQUEUE_SLIST_FOREACH_SAFE
    OR NOT SYSQUEUE_STAILQ_FOREACH_SAFE
    OR NOT SYSQUEUE_LIST_FOREACH_SAFE
    OR NOT SYSQUEUE_TAILQ_FOREACH_SAFE)
	include_directories(BEFORE ${EXTERNDIR}/queue)
endif ()

# unistd.h has some useful routines.
check_include_file(unistd.h HAVE_UNISTD_H)

configure_file("${ROOTDIR}/cmake/config.h.in" "${BINARYDIR}/config.h")

# ---------------------------------------------------------
# Include, libraries and executable
# ---------------------------------------------------------

include_directories(
	${BINARYDIR}
	${INCLUDES}
	${WING_INCLUDE_DIRS}
)

file(
	GLOB
	SOURCES
	${ROOTDIR}/src/*
)

add_executable(
	sd-tris
	${SOURCES}
	${EXTSOURCES}
)

target_link_libraries(
	sd-tris
	${WING_LIBRARIES}
	${LIBRARIES}
)

install(TARGETS sd-tris DESTINATION "${PATH_INSTALL_BIN}")

# data
install(DIRECTORY "${ROOTDIR}/data/"
    DESTINATION "${PATH_INSTALL_DATA}"
    PATTERN "data/*")

# score file on unix
if (NOT WIN32)
	install(DIRECTORY DESTINATION "${PATH_INSTALL_SCORE}")
endif ()

#
# Install NLS files.
#
if (HAVE_NLS)
	foreach (f "fr")
		install(FILES "${ROOTDIR}/po/${f}.mo"
		    DESTINATION "${PATH_INSTALL_NLS}/${f}/LC_MESSAGES/"
		    RENAME "sdtris.mo")
	endforeach()
endif ()

#
# chmod and setgid for score on Unix
#
if (UNIX)
	install(CODE "
	    execute_process(COMMAND chmod 2755 ${PATH_INSTALL_BIN}/sd-tris)
	    execute_process(COMMAND chown ${USER}:${GROUP} ${PATH_INSTALL_BIN}/sd-tris)
	    execute_process(COMMAND chmod 775 ${PATH_INSTALL_SCORE})
	    execute_process(COMMAND chown ${USER}:${GROUP} ${PATH_INSTALL_SCORE})
	")
endif ()

#
# CPack.
#

if (WIN32)
	set(CPACK_GENERATOR NSIS)
	
	set(CPACK_MONOLITHIC_INSTALL 1)

	set(CPACK_RESOURCE_FILE_LICENSE "${ROOTDIR}/LICENSE")
	set(CPACK_RESOURCE_FILE_README "${ROOTDIR}/README")
	
	set(CPACK_PACKAGE_EXECUTABLES "sd-tris" "SD-Tris")
	set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "sdtris")
endif ()

set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "SD-Tris game")
include(CPack)

# vim: set syntax=cmake:


More information about the CMake mailing list