Skip to content

Instantly share code, notes, and snippets.

@pcfreak30
Created May 31, 2016 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pcfreak30/dffffa1bf14637efb4e2e595a595fc84 to your computer and use it in GitHub Desktop.
Save pcfreak30/dffffa1bf14637efb4e2e595a595fc84 to your computer and use it in GitHub Desktop.
Google Native Client Hello Tutorial CMake CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
project(hello_tutorial)
if (NOT ENV{NACL_SDK_ROOT})
get_filename_component(PARENT_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
get_filename_component(NACL_SDK_ROOT "${PARENT_DIR}/.." REALPATH)
endif ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++98 -Wno-long-long -Wall -Wswitch-enum -pedantic -Werror")
set(GETOS python ${NACL_SDK_ROOT}/tools/getos.py)
set(OSHELPERS python ${NACL_SDK_ROOT}/tools/oshelpers.py)
set(RM "${OSHELPERS} rm")
execute_process(COMMAND ${GETOS}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE OSNAME
)
string(STRIP ${OSNAME} OSNAME)
get_filename_component(PNACL_TC_PATH ${NACL_SDK_ROOT}/toolchain/${OSNAME}_pnacl REALPATH)
set(CMAKE_C_COMPILER ${PNACL_TC_PATH}/bin/pnacl-clang)
set(CMAKE_CXX_COMPILER ${PNACL_TC_PATH}/bin/pnacl-clang++)
set(PNACL_FINALIZE ${PNACL_TC_PATH}/bin/pnacl-finalize)
include_directories(${NACL_SDK_ROOT}/include)
link_directories(${NACL_SDK_ROOT}/lib/pnacl/Release)
set(SOURCE_FILES hello_tutorial.cc)
add_executable(hello_tutorial ${SOURCE_FILES})
add_custom_command(
TARGET hello_tutorial POST_BUILD
COMMAND ${PNACL_FINALIZE} -o hello_tutorial.pexe hello_tutorial
DEPENDS hello_tutorial
)
set_source_files_properties( hello_tutorial.pexe PROPERTIES GENERATED TRUE )
target_link_libraries(hello_tutorial ppapi_cpp)
target_link_libraries(hello_tutorial ppapi)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment