forked from shi-yan/AssortedWidgets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
67 lines (40 loc) · 1.73 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
cmake_minimum_required (VERSION 3.7.2)
project (AssortedWidgets CXX)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
include_directories(AssortedWidgets)
message("build for " ${CMAKE_SYSTEM_NAME})
file(GLOB SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/AssortedWidgets/*.cpp")
file(GLOB DEMO_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/demo/*.cpp")
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Emscripten")
if(DEFINED HTML_TEMPLATE)
message("using template " ${HTML_TEMPLATE})
set(TEMPLATE_OPTION "--shell-file ${HTML_TEMPLATE}")
endif()
set(CMAKE_CXX_FLAGS "-O3 -s USE_SDL=2 -s WASM=1 -std=c++11 -s USE_SDL_IMAGE=2 -s FULL_ES2=1 -s SDL2_IMAGE_FORMATS='[\"png\"]' --preload-file ${CMAKE_CURRENT_SOURCE_DIR}/assets@assets ${CMAKE_CXX_FLAGS}")
add_executable (AssortedWidgets
${SOURCES}
${DEMO_SOURCES})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/assets/index.html
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
else()
set(CMAKE_CXX_FLAGS "--std=gnu++11 ${CMAKE_CXX_FLAGS}")
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
find_package(OpenGL REQUIRED)
set(OPENGLES2_gl_LIBRARY ${OPENGL_LIBRARIES})
else()
find_package(OpenGLES2 REQUIRED)
endif()
find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)
include_directories(${OPENGLES2_INCLUDE_DIR})
include_directories(${SDL2_INCLUDE_DIR})
include_directories(${SDL2IMAGE_INCLUDE_DIR})
message("sdl location: " ${SDL2_INCLUDE_DIR})
message("opengl es location: " ${OPENGLES2_INCLUDE_DIR})
add_executable (AssortedWidgets
${SOURCES}
${DEMO_SOURCES})
target_link_libraries(AssortedWidgets ${OPENGLES2_gl_LIBRARY} ${SDL2_LIBRARY} ${SDL2IMAGE_LIBRARY})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/assets
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
endif()