Skip to content
This repository has been archived by the owner on May 23, 2022. It is now read-only.

Cmake for Linux #3

Open
ghost opened this issue Apr 8, 2017 · 5 comments
Open

Cmake for Linux #3

ghost opened this issue Apr 8, 2017 · 5 comments

Comments

@ghost
Copy link

ghost commented Apr 8, 2017

Hi,
Thanks for the great example.
I am breaking my head to make this work on Linux. No matter what i do, I get:
Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

This is the make file:

``
cmake_minimum_required(VERSION 3.6)
find_package(PkgConfig REQUIRED)
set(CMAKE_BUILD_TYPE Release)
#set(CMAKE_BUILD_TYPE "Debug")
set(CXX_RELEASE_FLAGS = -O3 -march=native)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -lGL -lGLU -lglfw3 -lX11 -lXxf86vm -lXrandr -lpthread -lXi")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
#-std=c++0x
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_VERBOSE_MAKEFILE 1)
set(APP_VERSION_MAJOR 1)
set(APP_VERSION_MINOR 0)

#project(imgui-deepsleep)
#SET( PROJ_NAME imgui-deepsleep )
set(PROJ_NAME DeepSleepGUI) # the name of the executable

message(STATUS "PROJECT_SOURCE_DIR: ${PROJECT_SOURCE_DIR}")
message(STATUS "PROJ_NAME: ${PROJ_NAME}")
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
message(STATUS "CXX_RELEASE_FLAGS: ${CXX_RELEASE_FLAGS}")
set(CMAKE_BUILD_TYPE Release)
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
message("system: ${CMAKE_SYSTEM_PREFIX_PATH}")

Imgui itself

add_subdirectory(imgui)

include_directories(${PROJECT_SOURCE_DIR})

#target_link_libraries(${PROJ_NAME} imgui)

find Eigen3

find_package (Eigen3 REQUIRED)
include_directories (${EIGEN3_INCLUDE_DIRS})

glfw

find_package(glfw3 REQUIRED)
include_directories(${GLFW_INCLUDE_DIRS})
link_libraries(${GLFW_LIBRARY_DIRS})

find_package(GLEW QUIET CONFIG)

opengl

find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIRS})

glew

find_package(GLEW REQUIRED)
include_directories(${GLEW_INCLUDE_DIRS})

add and depend on OpenGL

find_package(OpenGL REQUIRED)
set(EXTERNAL_INCLUDE_DIRS ${EXTERNAL_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIR})
set(EXTERNAL_LIBRARIES ${EXTERNAL_LIBRARIES} ${OPENGL_LIBRARIES})

find_path(GLEW_INCLUDE_DIR GL/glew.h)
find_library(GLEW_LIBRARY NAMES GLEW glew32 glew glew32s PATH_SUFFIXES lib64)

find_package(GLEW REQUIRED)
if (GLEW_FOUND)
include_directories(${GLEW_INCLUDE_DIRS})
link_libraries(${GLEW_LIBRARIES})
endif()

#Boost
message("system: ${CMAKE_SYSTEM_PREFIX_PATH}")
find_package(Boost COMPONENTS system filesystem REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
message(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
message(STATUS "Boost_LIBRARIES: ${Boost_LIBRARIES}")
message(STATUS "Boost_VERSION: ${Boost_VERSION}")

if (APPLE)
# use OpenMP
include(FindOpenMP)
if(OPENMP_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
else()
message(SEND_ERROR "OpenMP not found.")
endif()
find_library(COCOA_LIBRARY Cocoa)
find_library(OpenGL_LIBRARY OpenGL)
find_library(IOKIT_LIBRARY IOKit)
find_library(COREVIDEO_LIBRARY CoreVideo)
SET(EXTRA_LIBS ${COCOA_LIBRARY} ${OpenGL_LIBRARY} ${IOKIT_LIBRARY} ${COREVIDEO_LIBRARY})
endif (APPLE)

set(PROJ_NAME DeepSleepGUI) # the name of the executable
SET( PROJ_SOURCES_DIR src)
SET( PROJ_SOURCES ${PROJ_SOURCES_DIR}/deepsleep/main.cpp)
SET( PROJ_INCLUDES include)
message(STATUS "PROJ_INCLUDES: ${PROJ_INCLUDES}")
SET( PROJ_HEADERS "")
SET(PROJECT_INCLUDE_DIR ${PROJ_INCLUDES})
SET(PROJECT_SOURCE_DIR ${PROJ_SOURCES})

include_directories("${PROJECT_INCLUDE_DIR}")
add_executable(${PROJ_NAME} ${PROJ_SOURCES} ${PROJ_HEADERS} ${PROJECT_INCLUDE_DIR})

#find_package(glm REQUIRED)

target_link_libraries(
${PROJ_NAME}
imgui
glfw
${GLFW_LIBRARIES}
${GLEW_LIBRARIES}
${EXTRA_LIBS}
${Boost_LIBRARIES}
${OPENGL_LIBRARIES}
)
``

Any help would be appreciated,

@ghost
Copy link
Author

ghost commented Apr 8, 2017

ocornut/imgui#1092

@ebachard
Copy link

Hello,

I got it building and working on Linux, using OpenGL 3.2 and 3.3 (no 4.x yet, sorry), cmake 3.5.1 + libGLEW + libGL + lbglfw3.

The attached patch (under MIT license) contains everything (including building instructions on Debian like distribution), and should not break the Mac OS X build imho.

full_diff.diff.txt

@morizotter
Copy link
Owner

🙄

@ebachard
Copy link

ebachard commented Jun 28, 2017

Is there something wrong with the patch ?

@morizotter
Copy link
Owner

I just "looking" 😊

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants