CMake编译CppCMS的html模板文件

核心提示:

1.这里主要用到CMAKE_SOURCE_DIR变量,它的值是我们工程的目录路径。

2.将welcome.tmpl文件放在src目录下,然后用CMake的add_custom_command命令设置自己额外的编译命令。


例子:

cmake_minimum_required(VERSION 2.8)
set(Boost_INCLUDE_DIR /usr/src/boost_1_47_0)
set(PROJECT_INCLUDE_DIR ../include)
find_package(Boost COMPONENTS system filesystem REQUIRED)
message("--------------------------------------------")
message(${Boost_INCLUDE_DIR})
message(${Boost_LIBRARIES})
message(${CMAKE_SOURCE_DIR})
message("--------------------------------------------")
include_directories(${Boost_INCLUDE_DIR} ${PROJECT_INCLUDE_DIR})
add_custom_command(
  OUTPUT ${CMAKE_SOURCE_DIR}/src/my_skin.cpp
  COMMAND cppcms_tmpl_cc ${CMAKE_SOURCE_DIR}/src/welcome.tmpl -o ${CMAKE_SOURCE_DIR}/src/my_skin.cpp
  DEPENDS welcome.tmpl
)

add_executable(main main.cpp hello.cpp my_skin.cpp)
target_link_libraries( main ${Boost_LIBRARIES} cppcms)




你可能感兴趣的:(html)