MODBUS is a communication protocol over a variety of  networks such as RS232 and Ethernet which was designed by Modicon.

It has been used widely since last several ten years and FreeMODBUS is a free implementation of this popular MODBUS protocol. 


Recently I wanted to have a tool to share data between some embedded devices over serial connection or ethernet and heard MODBUS can be a starting point for such purpose. So this is the outcome.


This MBServer ( a sample MODBUS TCP server) supports Qt5 but for now no GUI. Later I will put some GUI on it to talk with devices which can support MODBUS. For someone with interests on this can find source tree in the following link.  


https://github.com/seetime/freeMBServer/


How to build:


You need to have Cmake to generate Visual studio C++ project file.


First download source file and enter the root folder


cd <MBServer_root_dir>

mkdir build

cd build

cmake ..


With the project file generated, open it in Visual studio IDE and build and run.

 

For test, I used a MODBUS Diagnostick tool such as Modsak.  



Conclusion.


If someone need to develop application to talk with remote device over serial or Ethernet, MODBUS can be a option for such. This post could be helpful for someone searching or wanting to develop a basic MODBUS server tool. 


Posted by kevino
,

This article is written to show how CMake can be used to build OpenCL related application.

The sample code used here was grabbed from here and its main job is to apply simple Gaussian blur filter on test input image and saving output into a file. For better understanding about how OpenCL code works for Gaussian blur filtering, refer to the above link. I just wanted to build it on my machine to know how OpenCL application work so all credit on the source code should be given to Anteru which can be reached via https://anteru.net/2012/11/05/2022/.



Tested environment


1. Windows 7 with AMD OpenCL SDK

2. Windows 7 with Intel OpenCL SDK

3. MAC OSX 10.7


Below is CMakeLists.txt file used in this project.


CMakeLists.txt


As you can see, it is simple and no description on kernel CL source code because exe file will seek and compile it on run time. Please note that exe file should be located in the same folder with main source code to be able to read test input image and kernel CL code file.


For ones seeking zip file, use this file.

Anteru-opencltutorial.7z




Posted by kevino
,

QEMU can be very useful tool in developing wide range of software from simple application to even linux kernel itself for arm based embedded system. Here is to show how developing and debugging simple application for virtual arm based platform with QEMU is actually easy to people who are lazy so hate to move his/her finger to turn on real board and for poor people who do not have any real hardware.


Note: This post assume Host system is fairly new Ubuntu machine(For my case, its ubuntu 12.04 64bit)


Below is list for bullet items which this post focus.


1. How to build simple c application with a assembly library which can be callable in c function.

2. How to run the executable in Qemu

3. Debugging it with gdb



Phase 0. TOOL Setup


Before delving into programming, we need to check all necessary tools ready. Please refer to below command to install all of them. 


First install linaro image tools.


host$ sudo apt-get install linaro-image-tools


To get qemu to work with, there are two ways to building from source code and using apt-get but here I used apt-get as like below.


host$ sudo add-apt-repository ppa:linaro-maintainers/tools
host$ sudo apt-get update
host$ sudo apt-get install qemu-user-static qemu-system

To be able to compile c and assembly, we need to install crosstool chain for arm.


host$ sudo apt-get install gcc-arm-linux-gnueabi


Phase 1. Creating a simple application made up of c and assembly combination 


I wrote some articles in this site how to create CMake project so here I would like to show only source code without detailed explanation about it and why it is needed.


There are 4 files required in the project. 

1. main.c                                          # main c source code including main()

2. square.s                                       # assembly file containing functions callable in main() 

3. CMakeLists.txt                               # main cmake project file

4. toolchain-for-qemuarm.cmake          # cmake module used for cross compilation for arm target system


So just create below all 4 files in a $(EXAMPLE) directory.


main.c


square.s


CMakeLists.txt



toolchain-for-qemuarm.cmake


Note: Here I used gcc toolchain from Freescale site but you may use other popular toolchain also.


One you have those file, it is easy to build binary which will be run on qemu.


host$ mkdir build; cd build

host$ cmake -DCMAKE_TOOLCHAIN_FILE=../toolchain-for-qemuarm.cmake ..


Now you can check arm executable created correctly

host$ arm-linux-gnueabi-readelf ./program -a | more

ELF Header: Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2's complement, little endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: EXEC (Executable file) Machine: ARM Version: 0x1 Entry point address: 0x8538 Start of program headers: 52 (bytes into file) Start of section headers: 3592 (bytes into file) Flags: 0x5000002, has entry point, Version5 EABI

For source codes, download this. 

cassemtest.tar.gz



Phase 2. Test with QEmu

The built program depends on external libary called ld-linux.so.3 and this is arm side shared libary. So qemu need to know where to find correct shared library for this arm friendly executable. In below, I informed /usr/arm-linux-gnueabi which was created when I installed cross-toolchain mentioned in phase 0. ( FYI, when I used one included in freescale toolchain, system got corrupted for uncertain reason)

host$ qemu-arm-static -L /usr/arm-linux-gnueabi ./program

sum(1, 100) = 101 Hello, ARM World!

The printed message above shows that program ran as intended.


Phase 3. Debugging with Qemu + gdb

With gdb, user can debug application in source level. I already gave option "SET(CMAKE_BUILD_TYPE debug)" to include debug symbol in the executable by including one line in CMakeList.txt so the executable should contain symbol table in itself.

host$ qemu-arm-static -g 1234 -L /usr/arm-linux-gnueabi ./program


With -g 1234 option in the above command, qemu is waiting for gdb connection via port 1234 of localhost.

host$ sudo apt-get install gdb-multiarch

host$ gdb-multiarch

...

(gdb) file program

Reading symbols from /home/<user>/work/qemu/linaro/examples/cassemtest/build/program...done.

(gdb) target remote localhost:1234

Remote debugging using localhost:1234 [New Remote target] warning: Unable to find dynamic linker breakpoint function. GDB will be unable to debug shared library initializers and track explicitly loaded dynamic code. [Switching to Remote target] 0xf67dfc40 in ?? ()

(gdb) b main

Breakpoint 1 at 0x85f0: file /home/<user>/work/qemu/linaro/examples/cassemtest/main.c, line 8.

(gdb) c

Continuing. warning: Could not load shared library symbols for 2 libraries, e.g. /lib/libc.so.6. Use the "info sharedlibrary" command to see the complete listing. Do you need "set solib-search-path" or "set sysroot"? Breakpoint 1, main () at /home/<user>/work/qemu/linaro/examples/cassemtest/main.c:8 8 int a=1, b =100;


Conclusion


So far showed how simple application debugging with qemu can be done and hope this post will help app development for embedded system under qemu sandbox which will throw away any worry to break system due to SW bug.

   



Posted by kevino
,

On Mac, it was hard to find out how to capture web camera input to me and this is to share what i found in dealing with gstreamer to capture live webcam input on my Macbook running OS X 10.7.5.



To use GStreamer, the necessary package should be installed and the following link shows how to install it.


http://docs.gstreamer.com/display/GstSDK/Installing+on+Mac+OS+X


Before running gst-launch, few more steps are needed because the path containing the gst binaries may not be included in PATH env variable. I recommend that few symbolic links to gst binaries be created in /usr/bin/ path.

For example, at command line, run below command to create those files.


$ sudo ln -s /Library/Frameworks/GStreamer.framework/Versions/Current/bin/gst-launch-0.10 /usr/bin/gst-launch

$ sudo ln -s /Library/Frameworks/GStreamer.framework/Versions/Current/bin/gst-inspect-0.10 /usr/bin/gst-inspect


Now we can test whether gstreamer is working properly.


Example 1: Testing with pre-made video source in gstreamer and displaying it in a window.


$ gst-launch videotestsrc ! osxvideosink


Example 2: Displaying webcam input in a window


$ gst-launch autovideosrc ! osxvideosink



Example 3: Grabbing one frame from webcam and saving it as jpeg


$ gst-launch -v -e autovideosrc num-buffers=1 ! jpegenc ! filesink location=capture1.jpeg


So far, all examples above are shown as command line use case.

Before completing this post, here come a sample c source code with cmake script which will ease developing user application for one's own use. The source file is taken from gstreamer tutorial page at http://docs.gstreamer.com/pages/viewpage.action?pageId=327735 so if details about it is required, then you can check it also in the link.


This project source was tested with my macbook.



gst-example-prj.tar.7z


 

Posted by kevino
,

In Qt5, writing Cmake project for building Qt5 opengl app with optional shader seems to be little complicated comparing to previous Qt version(i.e Qt v5.0.2) and took time to figure out how to configure all necessary things. After many hours on this issue, I found one configuration to make possible to building Qt5 opengl app with Cmake and this post is to describe what I did with helps from various internet sources which will be listed below accordingly.


First thing to tell is preconditions before writing sources.


Precondition


1. OS: MS Windows 7

2. Qt version and toolkit: prebuilt Qt 5.1.0 msvc2010_opengl

3. Visual studio 2010

4. Windows SDK should be installed properly. : ie) c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\

5. CMake 2.8.11


If your system is different with the above precondition, CMakeLists.txt should be changed properly. Refer to the example CMakeLists.txt in this post. You can get a hint about how to edit.


Now it is time to introduce source code for building a simple Qt5 opengl shader app. 


Because main purpose to write up this post is to show how to create CMakeLists.txt to compile existing source codes, just copy and create all 3 files referring to this link:  http://qt-project.org/doc/qt-5.0/qtgui/openglwindow.html


And last file CMakeLists.txt.


CMakeLists.txt


Now we have all files to build up Qt5 shader app showing rotating triangle and time to run cmake to create visual studio project file for this app. If you are lucky to complete compilation and launching this app, then you will see a rotating triangle with help of Opengl shader in a window.



One last thing I want to note is that CMAKE_PREFIX_PATH in CMakeLists.txt MUST include proper paths in order to succeed compilation. As you can see in the above example, there are two paths are included.

First path is the location to find all neccessary Qt5 tools and must be same with the path in below picture. Below picture shows Qt Options dialog box in Visual studio 2010 through "Qt5" -> "Qt5 options" which is enabled if you installed visual studio addin for Qt5





Second path in CMAKE_PREFIX_PATH is required to compile with OpenGL library: glu32.lib and opengl32.lib. These files are included in Windows SDK so make sure this before starting compilation and also don't forget to include TARGET_LINK_LIBRARIES in the above example. Otherwise, opengl libraries will not be included in the project file generated by cmake.


Added 2013-09-23.


You may notice below error message on compilation.

Error message=> module machine type 'x64' conflicts with target machine type 'X86'


This error message happens when you create visual studio project file for 32 bit binary and try to compile against 64 bit library. The default behavior of running "cmake .." on 64 bit machine usually generates 32 bit project instead of 64 bit project file so this may cause compilation error.


Solution. Try to generate 64 bit visual studio project file using below command and compile binary with it.

cmake -G "Visual Studio 11 Win64" ..


Below is source code for your convenience.


qt5shader.7z


Posted by kevino
,

This is extended from my previous post: http://kevino.tistory.com/entry/CMakeqt5-Simple-example-for-CMake-QT5-package.


The source files in the above link is intended to be built on Host system and run on local machine. Here I will explain how to cross compile the same source codes  with almost same environment.


In order to develop QT app targeted for Arm embedded system, you need to first prepare Qt5 framework suitable for target board.


For i.MX6 Sabre SDB, refer to the following link: https://community.freescale.com/docs/DOC-94066. If you dont see any error in completing procedures described in the above link, you can find many example binaries created in $(TARGET_rootfs)/opt/qt5/examples and verify by running several examples.


Note. You may not see examples compiled even though you followed all steps. In this case, you can compile the examples manually by running below commands on Host system. If compilation is successful, then verify examples by running those on target board.


$ cd $(QTdir)/qtbase

$ make sub-examples


For now, before running cross compile commands, make sure that the following conditions are all met.


1. Target system is booted via nfs and "/" is mounted on ${TARGET_rootfs) of host system.

2. Qt5 for target board is installed at $(TARGET_rootfs)/opt/qt5 and examples at $(TARGET_rootfs)/opt/qt5/examples.

3. Need to verify whether Qt5 works by running example files and checking QT logo moving in 3D screen.

Target> cd /opt/qt5/examples

Target> ./opengl/hellogl_es2/hellogl_es2


If Qt5 is installed, then lets reuse the project source code which will be converted app for target board.


First we need to inform CMake that we will use cross compile and CMake dev team already made this solution since Cmake 2.6 version. 


For this, we can create a new cmake module similar to the below and remember its path.


Toolchain-freescale-imx6q.cmake


Now you can run cmake with crosscompile options to build the source codes. Assuming the above setup,


$ cd /home/<userid>/utils/ltib/rootfs/root

$ 7za x sample1.7z

$ cd sample1

$ mkdir build

$ cd build

$ cmake -DCMAKE_TOOLCHAIN_FILE=$(PATH_to_)/Toolchain-freescale-imx6q.cmake ..

$ make



Note. While running cmake, if you notice an error "Failed to find GLESv2 in "", then you can fix this error by modifying Qt5GuiConfigExtras.cmake at /home/<userid>/utils/ltib/rootfs/opt/qt5/lib/cmake/Qt5Gui/.


At 50 lines

- _qt5gui_find_extra_libs(OPENGL "GLESv2;GLESv2;EGL;GAL" "" "")

+ _qt5gui_find_extra_libs(OPENGL "GLESv2;GLESv2;EGL;GAL" ${CMAKE_FIND_ROOT_PATH}/usr/lib/ "")


I dont think this patch is good but it works for me so you can use this until official patch is ready. At least Qt 5.1.0 has this problem.


You can examine the exe file in target machine whether this Qt5 app can be run. If successful, now you are ready to develop Qt5 application running on Target board.




Posted by kevino
,

이번에도 CMake를 이용한 Qt5 용 프로젝트를 구성하는 방법에 대해 소개한다.


새롭게 이전 Qt 4.8버전하고 Qt5버전에서 Cmake 사용방법이 많이 바뀌어서 유의해야 할 부분을 중점으로 보여주기위한 글이므로 실제 프로젝트의 내용은 별거 없고 CmakeLists.txt파일 작성하는 부분을 중점적으로 보면 되겠다. 기본적인 정보는 다음의 링크를 참조해서 만들었다.


http://qt-project.org/doc/qt-5.0/qtdoc/cmake-manual.html#imported-targets


우선 시험 환경은 다음과 같다.


OS: Windows 7

CMake: version 2.8.11

Qt5: version 5.0.2


다른 내용은 별다른 것 없고 CMakeLists.txt를 주목해서 보는데 아래에 전체 소스를 표시하고 있다.


CMakeLists.txt



지금까지 연재해온 Cmake 시리즈와 다른 것은 별로 없고 눈여겨봐야 할 부분은 Visual Studio에서 디버깅시 보통의 경우 Qt5Widgetd.dll파일이 없다면서 실행에 실패할 것인데 이 경우 전역 변수 PATH에 Qt5 디렉토리를 추가해주면 문제가 해결될 것이나, 그렇지 않은 경우 VS용 프로젝트 파일의 설정값을 건드려서 정상동작하도록 만든 부분으로 그 설정은 아래와 같이 해주면 된다.


include(CreateLaunchers)

create_target_launcher(sample1 ENVIRONMENT  "PATH=${QTDIR}/bin")


실제로 동작가능한 프로젝트 파일은 아래에 올려두니 유용하게 쓰시기 바란다.


<추가> Linux에서 Qt5Widgets.cmake를 못찾는다는 오류가 나올때 해결방법

해당 qt5관련 cmake 모듈을 못찾는 경우에 발생한다. 이런 경우 CMAKE_PREFIX_PATH에 해당 위치를 지정해줘야 하는데 형식은 다음과 같다

if(UNIX)

set (CMAKE_PREFIX_PATH  <PATH_to_CmakeModules>)

endif(UNIX)


본인의 경우 다음과 같이 지정해주었다

set (CMAKE_PREFIX_PATH "/home/<userid>/Qt/5.1.0/gcc_64/lib/cmake")



sample1.7z


Posted by kevino
,

이번은 opencv를 이용하여 이미지 프로세싱을 하는 예제하나를 소개한다.


미리 얘기하지만 이글은 opencv와 cmake를 연동하는 방법에 중점을 둔 것으로 여기에 소개하는 opencv의 기능은 주된 관심대상이 아니고 예제를 보이기 위한 목적으로 타사이트에서 가져온 것이다. 제목에 나와 있다시피 이미지속의 사각형의 기울진 원근각을 자동으로 잡아주는 기능을 하는 예제로 원글의 주소는 다음과 같으니 좀더 자세한 내용을 확인하고 싶은 경우 도움이 될 것이다.


http://opencv-code.com/tutorials/automatic-perspective-correction-for-quadrilateral-objects/


본 글에서 전달하고자 하는 본론으로 들어간다.


1. 윈도우에서 CMake를 이용하여 컴파일하고자 하는 경우 대개 visual studio 20xx버전을 이용할텐데 한가지 애로사항이 visual studio 디버깅때에 사용될 기본 디렉토리 설정이 힘들다는 점이었다. 물론 프로젝트파일이 생성되고 나서 사용자가 직접 지정하면 되지만 여기에서는 CMakeFiles.txt에서 직접 설정할 수 있는 방법을 알아내어 여기에 소개한다.


일단 이것을 가능하게 하려면 다음 링크에서 제공하는 파일들이 필요하다.


https://github.com/rpavlik/cmake-modules


여기에 있는 파일들을 받아서 저장하자. 그럼 다음과 같은 디렉토리 구조가 되었는지 확인하자


:bin/

:${BASE_DIR} /cmake  /launcher-templates/

    +- quadrilateral.cpp

    +- CMakeLists.txt

                       +- CreateLaunchers.cmake

                       +- CleanDirectoryList.cmake


위와 같이 폴더 구조가 되었다고 가정할때 기본 작업 디렉토리를 설정하려면 CMakeLists.txt에 다음의 구절을 넣어야 한다.


SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})

include(CreateLaunchers)


create_target_launcher(quadrilateral WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../bin/")


위에서는 기본 작업 디렉토리가 CMakeLists.txt파일이 있는 위치에서 ../bin/으로 설정되었다. 여기에 opencv관련 dll파일들을 넣어놓으면 된다.


이용상 편의를 위해 위와 관련한 프로젝트를 아래 파일로 제공한다.


quadrilateral.7z



Posted by kevino
,

이 글은 MD3 model의 소개와 해당 소스코드를 제공하기 위해 작성되었다. 기존에 있는 소스코드를 그대로 사용하고 멀티플랫폼에서도 돌아갈수 있게 CMake를 이용한 컴파일이 가능하도록 환경을 추가한 것임을 밝힌다.


최근에 Skeleton Animation자료를 찾고 있던 와중에 괜찮은 사이트를 하나 발견했다.


해당사이트 가기

http://3dgep.com/?p=1053


MD5란 유명한 게임 DOOM3에서 사용된 모델들의 포맷인데 모델들의 Mesh정보와 함께 Skeleton animation 데이타도 같이 들어가 있고 관련된 소스및 기술자료도 많이 공개되어 있어 3D 엔진을 공부하는 개발자들에게 유용한 자료를 제공해주고 있다.


해당사이트에서는 소스 공개와 함께 설명까지 들어가 있어서 골격 에니메이션이 어떻게 동작하는지 공부할수 있게끔 도와주고 있는데 한가지 문제가 제공되는 소스코드가 윈도우즈용 비주얼 스튜디오에서만 돌아가게끔되어 있어서 이글을 작성하는 맥에서는 컴파일이 안된다는 점이었다. 해서 CMake를 이용하여 윈도우즈뿐만 아니라 맥에서도 컴파일 할 수 있게끔 소스를 추가하여 아래에서 제공한다.

관련 동영상은 원사이트에 나와 있으니 여기에서 생략한다.


[English]


Recently, I have searched for skeleton animation and found a very good introductive(?), actually not that super easy introductive to me, posting about MD5 model viewer. In that site, the original author wrote about MD5 model format and providing the model viewer source code what I wanted to find so desperately. 


The one problem is what I am using MAC for now and the only available build environment to compile the sources is visual studio project which is not available in MAC. So in order to make it compile even on MAC, I made some change into the original files and that is CMake integration.


So here I put cmake version below and someone who want other platform version such as Linux and MAC can use happily this version. Please find the below link for download.


Thanks for the original great posting to Jeremiah van Oosten.

Original link: http://3dgep.com/?p=1053


Original source code download :

https://docs.google.com/leaf?id=0B9NpHNF2In_uZDViNGM0MTYtNmQzNS00Zjg4LTgwMjItODkzNjE4ZWQ4M2Qx&sort=name&layout=list&num=50


CMake integrated version. Download here.

MD5Loader.tar.bz2






Posted by kevino
,

하나의 소스로 윈도우즈, 리눅스, 맥과 같은 다른 운영체제에서 돌아가는 그래픽 관련 애플리케이션을 작성할때 가장 좋은 구성을 개인적으로 QT 와 cmake패키지의 조합으로 본다. 이와 같은 구성으로 OpenGL이나 OpenCL까지 포함하는 패키지를 구성할 수 있으니 괜찮은 조합으로 생각되어 실제 작성해본 경험을 살려 실제 구동 가능한 소스를 짜는 방법에 대해 설명한다.


본 예제를 컴파일하기 위해 필요한 패키지를 적으면 다음과 같다.


1. CMake v2.8

2. QT 4.8


또한 이 예제는 Windows7과 MAC에서 작성되었다. 그리고 주의할점은 이글의 목적은 어느정도 QT와 Cmake를 사용해본 경험이 있는 사람들을 대상으로 한 것으로 중간에 도움이 될 부분이 필요한 사람들이 읽으면 좋은 수준으로 작성되었슴을 알린다.


애플리케이션 목표기능은 다음과 같다.

OpenGL을 이용하여 화면에 삼각형 출력. 대략 아래와 같은 화면을 출력하는 앱을 작성한다.




작업진행 순서

1. 소스 준비: 소스파일과 헤더 파일 그리고 ui파일을 준비한다.

2-1. qt project생성해서 컴파일 하는 방법

2-2. cmake를 이용한 컴파일 방법



우선 폴더를 하나 만들고 아래의 3개 소스를 작성한다.


main.cpp

GLWidget.h

GLWidget.cpp



다 작성했으면 main.cpp, GLWidget.cpp GLWidget.h 이렇게 세개의 파일이 생겼을 것이다.


그러면 두가지 컴파일 방법이 있는데 우선 쉬운 QT Project를 만드는 방법에 대해 설명한다.


1. QT project 작성


qt를 설치할때 같이 설치되는 qmake를 이용해서 프로젝트 파일을 만드는데 이때 옵션으로 필요한 부분을 추가할수 있는데 여기에서는 OpenGL를 이용하므로 이를 포함시킬수 있는 옵션을 같이 준다.

> qmake -project QT+="core gui opengl"


이렇게 하고 나면  .pro파일이 하나 생길 것인데 이를 QTCreator에서 불러서 컴파일 하면 된다.

이때 부가적으로 Makefile를 생성할 수도 있는데 다음의 명령어를 주면된다.


For MAC: > qmake -spec macx-g++ app.pro

For Window: > qmake app.pro


2. CMake를 이용한 빌드 방법

CMakeLists파일을 작성해야 하는데 문법을 미리 숙지할 필요가 있다. 필자의 여유부족으로 여기에서는 완성된 소스만 보여주고 넘어가기로 한다. 다음 파일을 작성한다.


CMakeLists.txt

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)


SET(TARGET qtglTest)

PROJECT(${TARGET})

SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)


SET(${TARGET}_HEADERS GLWidget.h)

SET(${TARGET}_SOURCES main.cpp GLWidget.cpp)


# Qt4

set(QT_USE_QTOPENGL TRUE)

#FIND_PACKAGE(Qt4 4.6.0 COMPONENTS QtCore QtGui QtOpenGL REQUIRED)

FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtOpenGL REQUIRED)


FIND_PACKAGE(OpenGL)

FIND_PACKAGE(GLUT)

FIND_PACKAGE(GLEW)



QT4_WRAP_CPP(${TARGET}_HEADERS_MOC ${${TARGET}_HEADERS})



INCLUDE(${QT_USE_FILE})

ADD_DEFINITIONS(${QT_DEFINITIONS})


#ADD_DEFINITIONS(-DOBJ_SOURCE_DIR="${${TARGET}_SOURCES}")

MESSAGE ("-- ${TARGET}_SOURCES: ${${TARGET}_SOURCES}")

MESSAGE ("-----------------------------------------")

MESSAGE ("-- QT_INCLUDE_DIR: ${QT_INCLUDE_DIR}")

MESSAGE ("-- QT_LIBRARIES: ${QT_LIBRARIES}")


INCLUDE_DIRECTORIES(

    ${QT_INCLUDE_DIR}

    ${GLUT_INCLUDE_DIR}

    ${OPENGL_INCLUDE_DIR}

    ${GLEW_INCLUDE_PATH}

)



ADD_EXECUTABLE( ${TARGET} ${${TARGET}_SOURCES} ${${TARGET}_HEADERS_MOC})

TARGET_LINK_LIBRARIES ( ${TARGET}

    ${QT_LIBRARIES}

    ${GLUT_LIBRARIES}

    ${OPENGL_LIBRARIES}

    ${GLEW_LIBRARY}

)

#TARGET_LINK_LIBRARIES(clTut ${OPENCL_LIBRARY})



작성이 되었으면 다음의 순서를 진행하여 컴파일 한다.

> mkdir build
> cd build
> cmake ..
> make


이 결과로 생긴 앱을 실행하면 위의 화면을 볼 수 있다.


여기서 필요한 몇가지 cmake 스크립트 파일에 대한 설명을 하지 않았는데 다음의 파일을 받아서 소스폴더에 cmake이름의 폴더를 만들고 집어넣고 위의 명령어를 실행해야 오류가 생기지 않음을 언급해둔다.


전체 소스 파일 받기


qtglTest.zip




Posted by kevino
,