[CMake] Failed to build C++ source with CMakeLists.txt

jupiter jupiter.hce at gmail.com
Sat Aug 5 07:28:37 EDT 2017


Hi,

I have built many open sources with gcc 4.9.1 on CentOS 6.8 platform, but I
could not build this one and I have no idea what was wrong with this
CMakeLists.txt, I have attached both CMakeLists.txt and CMakeError.log,
appreciate any clues what was missing. Thank you.


$ ls /usr/local/cppcms/1.1.0/include
booster  cppcms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170805/4fd59ff3/attachment.html>
-------------- next part --------------
cmake_minimum_required(VERSION 2.6)
project(cppcms)

include_directories(${CMAKE_SOURCE_DIR})

# Options 

option(STATIC_VIEW "Build Static View instead of dynamically loaded one" OFF)

if(WIN32 OR CYGWIN)
	add_definitions(-DDLL_EXPORT)
endif()


# Dependencies

find_library(LIB_BOOSTER booster)
find_library(LIB_CPPCMS cppcms)
find_library(LIB_CPPDB cppdb)
find_program(EXE_TMPL_CC cppcms_tmpl_cc)
find_program(EXE_MSGFMT msgfmt)
find_program(EXE_SQLITE3 sqlite3)

find_path(INC_BOOSTER booster/config.h)
find_path(INC_CPPCMS cppcms/config.h)
find_path(INC_CPPDB cppdb/frontend.h)

# Sources

set(VIEW_NAME simple)

set(VIEW_TEMPLATES 
	view/master.tmpl
	view/forums.tmpl 
	view/thread.tmpl)

set(MB_SRC
	apps/master.cpp
	apps/thread.cpp
	apps/forums.cpp
	apps/mb.cpp
	apps/main.cpp)

set(MB_LANG he)

# Actual Build

include_directories(${INC_BOOSTER})
include_directories(${INC_CPPCMS})
include_directories(${INC_CPPDB})

set(VIEW_SRC "${CMAKE_CURRENT_BINARY_DIR}/${VIEW_NAME}.cpp")

add_custom_command(
	OUTPUT ${VIEW_SRC}
	COMMAND ${EXE_TMPL_CC}
		-s "${VIEW_NAME}"
		${TMPL_CC_PARAMS}
		-o ${VIEW_SRC}
		${VIEW_TEMPLATES}
	WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
	DEPENDS ${VIEW_TEMPLATES})


if(STATIC_VIEW)
	set(MB_SRC ${MB_SRC} ${VIEW_SRC})
else()
	add_library(${VIEW_NAME} SHARED ${VIEW_SRC})
	target_link_libraries(${VIEW_NAME} ${LIB_CPPCMS})
	target_link_libraries(${VIEW_NAME} ${LIB_BOOSTER})
endif()


add_executable(mb ${MB_SRC})
target_link_libraries(mb ${LIB_CPPCMS})
target_link_libraries(mb ${LIB_BOOSTER})
target_link_libraries(mb ${LIB_CPPDB})

if(EXE_MSGFMT)
	set(MO_FILES)
	foreach(LANG ${MB_LANG}) 
		set(PO locale/${LANG}/LC_MESSAGES/mb.po)
		set(MO ${CMAKE_CURRENT_BINARY_DIR}/locale/${LANG}/LC_MESSAGES/mb.mo)
		file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/locale/${LANG}/LC_MESSAGES")
		set(MO_FILES ${MO_FILES} ${MO})
		add_custom_command(
			OUTPUT ${MO}
			COMMAND ${EXE_MSGFMT} ${PO} -o ${MO}
			WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
			DEPENDS ${PO})
	endforeach()
	add_custom_target(create-mo ALL DEPENDS ${MO_FILES})
else()
	message("-- msgfmt not found, translations not generatied")
endif()

if(EXE_SQLITE3)
	add_custom_command(
		OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mb.db
		COMMAND ${EXE_SQLITE3} < ${CMAKE_CURRENT_SOURCE_DIR}/model/sqlite3.sql ${CMAKE_CURRENT_BINARY_DIR}/mb.db)
	add_custom_target(sqlitedb ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/mb.db)
endif()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CMakeError.log
Type: text/x-log
Size: 2166 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170805/4fd59ff3/attachment.bin>


More information about the CMake mailing list