<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="th">
	<id>https://theory.cpe.ku.ac.th/wiki/index.php?action=history&amp;feed=atom&amp;title=CMake%2Fexternal_libraries</id>
	<title>CMake/external libraries - ประวัติรุ่นแก้ไข</title>
	<link rel="self" type="application/atom+xml" href="https://theory.cpe.ku.ac.th/wiki/index.php?action=history&amp;feed=atom&amp;title=CMake%2Fexternal_libraries"/>
	<link rel="alternate" type="text/html" href="https://theory.cpe.ku.ac.th/wiki/index.php?title=CMake/external_libraries&amp;action=history"/>
	<updated>2026-04-10T12:59:56Z</updated>
	<subtitle>ประวัติรุ่นแก้ไขของหน้านี้ในวิกิ</subtitle>
	<generator>MediaWiki 1.33.1</generator>
	<entry>
		<id>https://theory.cpe.ku.ac.th/wiki/index.php?title=CMake/external_libraries&amp;diff=8826&amp;oldid=prev</id>
		<title>Cardcaptor เมื่อ 17:01, 12 พฤษภาคม 2553</title>
		<link rel="alternate" type="text/html" href="https://theory.cpe.ku.ac.th/wiki/index.php?title=CMake/external_libraries&amp;diff=8826&amp;oldid=prev"/>
		<updated>2010-05-12T17:01:38Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;th&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;←รุ่นแก้ไขก่อนหน้า&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;รุ่นแก้ไขเมื่อ 17:01, 12 พฤษภาคม 2553&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l164&quot; &gt;แถว 164:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;แถว 164:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     CMAKE_MINIMUM_REQUIRED(VERSION 2.6)&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     CMAKE_MINIMUM_REQUIRED(VERSION 2.6)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     PROJECT(sample)&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     PROJECT(sample)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     IF(WIN32)&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     IF(WIN32)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         SET(__WIN_PLATFORM__ &amp;quot;ON&amp;quot;)&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         SET(__WIN_PLATFORM__ &amp;quot;ON&amp;quot;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l170&quot; &gt;แถว 170:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;แถว 170:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         SET(__WIN_PLATFORM__ &amp;quot;OFF&amp;quot;)&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         SET(__WIN_PLATFORM__ &amp;quot;OFF&amp;quot;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     ENDIF(WIN32)&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     ENDIF(WIN32)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     IF(UNIX)&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     IF(UNIX)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         IF(APPLE)&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         IF(APPLE)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l183&quot; &gt;แถว 183:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;แถว 183:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         SET(__UNIX_PLATFORM__ &amp;quot;OFF&amp;quot;)&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         SET(__UNIX_PLATFORM__ &amp;quot;OFF&amp;quot;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     ENDIF(UNIX)&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     ENDIF(UNIX)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     FIND_PACKAGE(OpenGL REQUIRED)&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     FIND_PACKAGE(OpenGL REQUIRED)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     FIND_PACKAGE(GLUT REQUIRED)&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     FIND_PACKAGE(GLUT REQUIRED)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     ADD_SUBDIRECTORY(square)&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     ADD_SUBDIRECTORY(square)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     CONFIGURE_FILE( config.h.in ${CMAKE_SOURCE_DIR}/config.h )&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     CONFIGURE_FILE( config.h.in ${CMAKE_SOURCE_DIR}/config.h )&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l216&quot; &gt;แถว 216:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;แถว 216:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR})&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR})&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     ADD_EXECUTABLE(square square.cpp)&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     ADD_EXECUTABLE(square square.cpp)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     TARGET_LINK_LIBRARIES(square ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES})&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     TARGET_LINK_LIBRARIES(square ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES})&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l226&quot; &gt;แถว 226:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;แถว 226:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     INCLUDE_DIRECTORIES(&amp;lt;ไดเรคทอรี 1&amp;gt; &amp;lt;ไดเรคทอรี 2&amp;gt; ...)&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     INCLUDE_DIRECTORIES(&amp;lt;ไดเรคทอรี 1&amp;gt; &amp;lt;ไดเรคทอรี 2&amp;gt; ...)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;    &lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;โดยที่เราสามารถใส่ไดเรคทอรีกี่ไดเรคทอรีก็ได้ในวงเล็บ&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;โดยที่เราสามารถใส่ไดเรคทอรีกี่ไดเรคทอรีก็ได้ในวงเล็บ&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;หลังจากสั่งคำสั่งนี้แล้ว คอมไพเลอร์จะคอมไพล์ target ทุก target&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;หลังจากสั่งคำสั่งนี้แล้ว คอมไพเลอร์จะคอมไพล์ target ทุก target&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Cardcaptor</name></author>
		
	</entry>
	<entry>
		<id>https://theory.cpe.ku.ac.th/wiki/index.php?title=CMake/external_libraries&amp;diff=8825&amp;oldid=prev</id>
		<title>Cardcaptor: หน้าที่ถูกสร้างด้วย &#039;แม้ปัจจุบันมีไลบรารีภาษา C/C++ ที่สามารถใช้ได้บนแพ…&#039;</title>
		<link rel="alternate" type="text/html" href="https://theory.cpe.ku.ac.th/wiki/index.php?title=CMake/external_libraries&amp;diff=8825&amp;oldid=prev"/>
		<updated>2010-05-12T17:00:39Z</updated>

		<summary type="html">&lt;p&gt;หน้าที่ถูกสร้างด้วย &amp;#039;แม้ปัจจุบันมีไลบรารีภาษา C/C++ ที่สามารถใช้ได้บนแพ…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;หน้าใหม่&lt;/b&gt;&lt;/p&gt;&lt;div&gt;แม้ปัจจุบันมีไลบรารีภาษา C/C++ ที่สามารถใช้ได้บนแพลตฟอร์มพลายแพลตฟอร์มอยู่มากมาย&lt;br /&gt;
แต่การใช้ไลบรารีเหล่านั้นพัฒนาโปรแกรมยังเป็นเรื่องที่ยุ่งยาก เนื่องจากแพลตฟอร์มต่างๆ&lt;br /&gt;
เก็บไลบรารีเหล่านี้ไว้ที่ไดเรคต่างๆ กัน &lt;br /&gt;
CMake มีสคริปต์สำหรับค้นหาแตำแหน่งของไลบรารีที่ได้รับความนิยมอยู่หลายๆ ไลบรารี&lt;br /&gt;
ทำให้การใช้ไลบรารีเหล่านี้เขียนโปรแกรมที่ใช้ได้หลายๆ แพลตฟอร์มเป็นเรื่องง่าย &lt;br /&gt;
(แต่ก็ยังมีรายละเอียดมากพอสมควร)&lt;br /&gt;
ในบทความนี้เราจะมาศึกษาวิธีการเรียกใช้สคริปต์เหล่านี้โดยใช้ไลบรารี &lt;br /&gt;
[http://en.wikipedia.org/wiki/OpenGL OpenGL] และ [http://en.wikipedia.org/wiki/GLUT GLUT]&lt;br /&gt;
เป็นตัวอย่าง&lt;br /&gt;
&lt;br /&gt;
== ติดตั้ง GLUT บน Windows ==&lt;br /&gt;
&lt;br /&gt;
=== สร้างไดเรคทอรีสำหรับเก็บไลบรารี ===&lt;br /&gt;
&lt;br /&gt;
หากผู้อ่านใช้ Linux หรือ Mac OS X &lt;br /&gt;
ก็ไม่มีความจำเป็นจะต้องติดตั้งไลบรารีสองไลบรารีข้างต้นแต่อย่างใด&lt;br /&gt;
เนื่องจากมันติดมากับระบบปฏิบัติการแล้ว&lt;br /&gt;
อย่างไรก็ดีผู้อ่านที่ใช้ Windows จะต้องมีการติดตั้ง GLUT&lt;br /&gt;
ให้ CMake สามารถค้นหาเจอได้ วิธีการติดตั้งนี้ความจริงแล้วมีหลายวิธี &lt;br /&gt;
แต่ผู้เขียนจะนำเสนอวิธีการติดตั้งของตัวเองไว้ ณ ที่นี้&lt;br /&gt;
&lt;br /&gt;
ผู้เขียนได้สร้างไดเรคทอรีหนึ่งในฮาร์ดดิสก์ไว้สำหรับเก็บไลบรารีภาษา C/C++&lt;br /&gt;
โดยเฉพาะ ในบทความนี้ขอสมมติให้เป็นไดเรคทอรี C:\usr\local&lt;br /&gt;
เพื่อให้คล้ายๆ กับไดเรคทอรีใน Unix &lt;br /&gt;
ในไดเรคทอรีนี้จะได้เรคทอรีย่อดังสองไดเรคทอรีที่สำคัญคือ&lt;br /&gt;
&lt;br /&gt;
* C:\usr\local\include สำหรับเก็บ header file&lt;br /&gt;
* C:\usr\local\lib สำหรับเก็บไลบรารีที่อยู่ในรูปไฟล์ .lib&lt;br /&gt;
* C:\usr\local\bin สำหรับเก็บไลบรารีที่อยู่ในรูปไฟล์ .dll&lt;br /&gt;
&lt;br /&gt;
หลังจากนั้นผู้เขียนจะกำหนด environmental variable ของ Windows&lt;br /&gt;
สองตัวดังต่อไปนี้ (คุณสามารถดูวิธีกำหนด environmental variable ได้ที่&lt;br /&gt;
[http://vlaurie.com/computers2/Articles/environment.htm เวบไซต์นี้]) &lt;br /&gt;
&lt;br /&gt;
* เพิ่ม C:\usr\local\bin เข้าในตัวแปร PATH ซึ่งมีอยู่แล้ว&lt;br /&gt;
* สร้างตัวแปร CMAKE_PREFIX_PATH ใหม่และให้มันมีค่าเท่ากับ C:\usr\local&lt;br /&gt;
&lt;br /&gt;
CMake จะดูค่าของตัวแปร CMAKE_PREFIX_PATH เวลามันค้นหาไดเรคทอรีของไลบรารีต่างๆ&lt;br /&gt;
การกำหนด CMAKE_PREFIX_PATH ไม่มีความจำเป็นใน Linux หรือ Mac OS&lt;br /&gt;
เนื่องจากแพลตฟอร์มเหล่านั้นมี[http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard มาตรฐานโครงสร้างไดเรคทอรี]กำหนดอยู่ตายตัว&lt;br /&gt;
ไม่เหมือนกับ Windows&lt;br /&gt;
&lt;br /&gt;
=== ลง GLUT ===&lt;br /&gt;
&lt;br /&gt;
คุณสามารถดาวน์โหลด GLUT สำหรับ Windows ได้ที่[http://www.xmission.com/~nate/glut.html เวบไซต์ของ Nate Robins]&lt;br /&gt;
เราแนะนำให้คุณดาวน์โหลด glut-3.7.6-bin.zip มาแล้วขยายมันออก แล้วให้คัดลอกไฟล์เหล่านี้ใส่ไดเรคทอรีดังต่อไปนี้&lt;br /&gt;
&lt;br /&gt;
* glut32.dll ลงใน  C:\usr\local\bin&lt;br /&gt;
* glut32.lib ลงใน C:\usr\local\lib&lt;br /&gt;
* glut.h ลงใน C:\usr\local\include\GL โดยที่คุณต้องสร้างไดเรคทอรี C:\usr\local\include\GL ขึ้นมาก่อน&lt;br /&gt;
&lt;br /&gt;
# โปรแกรมวาดรูปสี่เหลี่ยมจัตุรัส&lt;br /&gt;
&lt;br /&gt;
เราจะเขียนโปรแกรม square สำหรับวาดรูปสี่เหลี่ยมจัตุรัสโดยใช้ OpenGL และ GLUT&lt;br /&gt;
อันดับแรกเราจะสร้างไดเรคทอรีของโปรเจคซึ่งมีไฟล์อยู่ดังต่อไปนี้&lt;br /&gt;
&lt;br /&gt;
    sample/&lt;br /&gt;
        build/&lt;br /&gt;
        src/&lt;br /&gt;
            CMakeLists.txt&lt;br /&gt;
            config.h.in&lt;br /&gt;
            square/&lt;br /&gt;
                CMakeLists.txt&lt;br /&gt;
                square.cpp&lt;br /&gt;
                &lt;br /&gt;
ซึ่งเหมือนกับโครงสร้างไดเรคทอรีใน[[CMake/config.h|บทความเกี่ยวกับการตรวจสอบแพลตฟอร์ม]]ก่อนหน้านี้&lt;br /&gt;
ไฟล์ config.h.in นั้นมีเนื้อหาเหมือนเดิม ที่เปลี่ยนคือไฟล์ CMakeLists.txt ทั้งสองไฟล์&lt;br /&gt;
แต่เราจะพูดถึงมันทีหลัง&lt;br /&gt;
&lt;br /&gt;
ไฟล์ square.cpp มีเนื้อหาดังนี้&lt;br /&gt;
&lt;br /&gt;
&amp;lt;geshi lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;../config.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#ifdef __WIN_PLATFORM__&lt;br /&gt;
#include &amp;lt;windows.h&amp;gt;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
#ifdef __MAC_PLATFORM__&lt;br /&gt;
#include &amp;lt;OpenGL/gl.h&amp;gt;&lt;br /&gt;
#include &amp;lt;OpenGL/glu.h&amp;gt;&lt;br /&gt;
#include &amp;lt;GLUT/glut.h&amp;gt;&lt;br /&gt;
#else&lt;br /&gt;
#include &amp;lt;GL/gl.h&amp;gt;&lt;br /&gt;
#include &amp;lt;GL/glu.h&amp;gt;&lt;br /&gt;
#include &amp;lt;GL/glut.h&amp;gt;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
void display()&lt;br /&gt;
{&lt;br /&gt;
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);&lt;br /&gt;
    glClearDepth(1.0f);&lt;br /&gt;
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);&lt;br /&gt;
    glColor3f(1.0f, 1.0f, 1.0f);&lt;br /&gt;
    glBegin(GL_QUADS);&lt;br /&gt;
    glVertex2f(-0.5f, -0.5f);&lt;br /&gt;
    glVertex2f( 0.5f, -0.5f);&lt;br /&gt;
    glVertex2f( 0.5f,  0.5f);&lt;br /&gt;
    glVertex2f(-0.5f,  0.5f);&lt;br /&gt;
    glEnd();&lt;br /&gt;
    glutSwapBuffers();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main(int argc, char **argv)&lt;br /&gt;
{&lt;br /&gt;
    glutInit(&amp;amp;argc, argv);&lt;br /&gt;
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);&lt;br /&gt;
    glutCreateWindow(&amp;quot;CMake with OpenGL and GLUT&amp;quot;);&lt;br /&gt;
    glutInitWindowSize(512, 512);&lt;br /&gt;
    glutDisplayFunc(display);&lt;br /&gt;
    glutMainLoop();&lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/geshi&amp;gt;&lt;br /&gt;
&lt;br /&gt;
สังเกตว่าในโค้ดข้างบน ก่อนที่ถึงโค้ดที่ทำงานจริง&lt;br /&gt;
มีโค้ดส่วนหนึ่งที่ใช้ include ไฟล็ที่เหมาะสมซึ่งค่อนข้างยาว (13 บรรทัด)&lt;br /&gt;
แสดงให้เห็นถึงความยุ่งยากในการเขียนโปรแกรมภาษา C++ ให้ทำงานได้หลายแพลตฟอร์ม&lt;br /&gt;
ถึงแม้ว่าเราจะมีตัวช่วยอย่าง CMake อยู่ก็ตาม &lt;br /&gt;
(ดังนั้นจึงไม่แปลกดอกที่คนหันไปใช้ Java หรือ C# มากกว่า)&lt;br /&gt;
&lt;br /&gt;
การใช้ OpenGL และ GLUT มีรายละเอียดพอสรุปได้ดังนี้&lt;br /&gt;
&lt;br /&gt;
* แพลตฟอร์มต่างๆ เก็บ OpenGL อยู่คนละที่กัน &lt;br /&gt;
ดังนั้นเราจึงต้องมีการใช้ preprocessor macro ใน config.h&lt;br /&gt;
สำหรับตรวจสอบแพลตฟอร์ม และนี่เป็นเหตุผลที่เราต้อง include ../config.h&lt;br /&gt;
&lt;br /&gt;
* ใน Windows ก่อนที่เราจะ include GL/gl.h เราจะต้องทำการ&lt;br /&gt;
include windows.h ก่อนเสมอ แต่ในแพลตฟอร์มอื่นเราไม่ต้องทำเช่นนั้น&lt;br /&gt;
&lt;br /&gt;
* หากผู้อ่านติดตั้ง GLUT ตามที่ผู้เขียนบอกไว้แล้ว&lt;br /&gt;
วิธีการ include ไฟล์ของ OpenGL และ GLUT ใน Windows และใน Linux&lt;br /&gt;
จะมีลักษณะเหมือนกัน กล่าวคือทั้งสามไฟล์อยู่ในไดเรคทอรี GL&lt;br /&gt;
ซึ่งอยู่ในไดเรคทอรีที่ CMake ไปหา OpenGL และ GLUT เจออีกที&lt;br /&gt;
&lt;br /&gt;
* ในทางกลับกัน Mac OS เก็บ OpenGL และ GLUT แยกกัน&lt;br /&gt;
แถมยังเก็บไม่เหมือนของระบบอื่นๆ เลย ทำให้ชื่อไฟล์ header ของ OpenGL &lt;br /&gt;
ต้องมี OpenGL/ นำหน้า ส่วน header ของ GLUT ต้องมี GLUT/ นำหน้า&lt;br /&gt;
&lt;br /&gt;
== คำสั่ง FIND_PACKAGE ==&lt;br /&gt;
&lt;br /&gt;
CMake เรียกไลบรารีภายนอกว่า &amp;quot;package&amp;quot; และมีคำสั่ง FIND_PACKAGE&lt;br /&gt;
ไว้สำหรับค้นหาที่อยู่และข้อมูลจำเป็นอื่นๆ ของ package ที่ผู้ใช้กำหนด&lt;br /&gt;
คำสั่ง FIND_PACKAGE มีรูปแบบการใช้ดังต่อไปนี้&lt;br /&gt;
&lt;br /&gt;
    FIND_PACKAGE(&amp;lt;ชื่อ package&amp;gt;)&lt;br /&gt;
    &lt;br /&gt;
และถ้าหากการคอมไพล์โปรเจคต้องใช้ package ที่เราต้องการหา เราอาจสั่ง&lt;br /&gt;
&lt;br /&gt;
    FIND_PACKAGE(&amp;lt;ชื่อ package&amp;gt;) REQUIRED)&lt;br /&gt;
    &lt;br /&gt;
เพื่อบอกให้ CMake พิมพ์ข้อความแสดงความผิดพลาดหากหา package ไม่เจอ&lt;br /&gt;
&lt;br /&gt;
ในกรณีของโปรเจคในบทความนี้ เราจะใช้ package สองตัวคือ OpenGL และ&lt;br /&gt;
GLUT (คุณสามารถดู package อื่นๆ ที่ CMake ค้นหาเป็นได้จาก &lt;br /&gt;
[http://www.cmake.org/cmake/help/cmake-2-8-docs.html#section_Standard%20CMake%20Modules documentation ของ CMake])&lt;br /&gt;
ฉะนั้นเราจะต้องมีการเพิ่มสคริปต์สองบรรทัดข้างล่างนี้&lt;br /&gt;
&lt;br /&gt;
    FIND_PACKAGE(OpenGL REQUIRED)&lt;br /&gt;
    FIND_PACKAGE(GLUT REQUIRED)&lt;br /&gt;
    &lt;br /&gt;
ลงในไฟล์ src/CMakeLists.txt ดังต่อไปนี้&lt;br /&gt;
&lt;br /&gt;
    CMAKE_MINIMUM_REQUIRED(VERSION 2.6)&lt;br /&gt;
    PROJECT(sample)&lt;br /&gt;
&lt;br /&gt;
    IF(WIN32)&lt;br /&gt;
        SET(__WIN_PLATFORM__ &amp;quot;ON&amp;quot;)&lt;br /&gt;
    ELSE(WIN32)&lt;br /&gt;
        SET(__WIN_PLATFORM__ &amp;quot;OFF&amp;quot;)&lt;br /&gt;
    ENDIF(WIN32)&lt;br /&gt;
&lt;br /&gt;
    IF(UNIX)&lt;br /&gt;
        IF(APPLE)&lt;br /&gt;
            SET(__MAC_PLATFORM__ &amp;quot;ON&amp;quot;)&lt;br /&gt;
            SET(__UNIX_PLATFORM__ &amp;quot;OFF&amp;quot;)&lt;br /&gt;
        ELSE(APPLE)&lt;br /&gt;
            SET(__MAC_PLATFORM__ &amp;quot;OFF&amp;quot;)&lt;br /&gt;
            SET(__UNIX_PLATFORM__ &amp;quot;ON&amp;quot;)&lt;br /&gt;
        ENDIF(APPLE)&lt;br /&gt;
    ELSE(UNIX)&lt;br /&gt;
        SET(__MAC_PLATFORM__ &amp;quot;OFF&amp;quot;)&lt;br /&gt;
        SET(__UNIX_PLATFORM__ &amp;quot;OFF&amp;quot;)&lt;br /&gt;
    ENDIF(UNIX)&lt;br /&gt;
&lt;br /&gt;
    FIND_PACKAGE(OpenGL REQUIRED)&lt;br /&gt;
    FIND_PACKAGE(GLUT REQUIRED)&lt;br /&gt;
&lt;br /&gt;
    ADD_SUBDIRECTORY(square)&lt;br /&gt;
&lt;br /&gt;
    CONFIGURE_FILE( config.h.in ${CMAKE_SOURCE_DIR}/config.h )&lt;br /&gt;
&lt;br /&gt;
สังเกตเราใส่คำสั่ง FIND_PACKAGE ไว้ก่อนการประกาศ target ต่างๆ ทุก target&lt;br /&gt;
เนื่องจาก target ที่เราประกาศอาจต้องการใช้ package ที่เราหาในภายหลัง&lt;br /&gt;
&lt;br /&gt;
# ให้ target เรียกใช้ package&lt;br /&gt;
&lt;br /&gt;
ก่อนที่เราจะคอมไพล์ target หนึ่งที่เรียกใช้ package หนึ่งได้นั้น&lt;br /&gt;
เราจะต้องให้ข้อมูลสองประการต่อไปนี้กับคอมไพเลอร์&lt;br /&gt;
&lt;br /&gt;
1. ไดเรคทอรีที่ให้คอมไพเลอร์ไปหาไฟล์ header ของ package&lt;br /&gt;
&lt;br /&gt;
2. ไฟล์ไลบรารีที่คอมไพเลอร์จะต้องลิงก์เข้ากับผลลัพธ์ที่ได้จากการคอมไพล์ไฟล์ของ target&lt;br /&gt;
&lt;br /&gt;
หลังจากใช้ FIND_PACKAGE หาที่อยู่ของ package แล้ว&lt;br /&gt;
โดยมากข้อมูลไดเรคทอรีที่อยู่ของไฟล์ header นั้นจะอยู่ในตัวแปรชื่อ&lt;br /&gt;
&amp;lt;ชือ่ package ตัวพิมพ์ใหญ่&amp;gt;_INCLUDE_DIR และข้อมูลไลบรารีที่จะต้องลิงก์จะอยู่ตัวแปรชื่อ&lt;br /&gt;
&amp;lt;ชื่อ package ตัวพิมพ์ใหญ่&amp;gt;_LIBRARIES ฉะนั้นชื่อตัวแปรที่เก็บข้อมูลเหล่านี้ของ&lt;br /&gt;
OpenGL และ GLUT ได้แก่ OPENGL_INCLUDE_DIR, OPENGL_LIBRARIES,&lt;br /&gt;
GLUT_INCLUDE_DIR, และ GLUT_LIBRARIES&lt;br /&gt;
&lt;br /&gt;
เราควรจะบอกข้อมูลข้างต้น**เป็นราย target ไป** เนื่องจาก target แต่ละตัวอาจใช้&lt;br /&gt;
package ไม่เหมือนกัน ดังนั้นคำสั่งที่ใช้กำหนดข้อมูลเหล่านี้จึงควรอยู่ใน&lt;br /&gt;
CMakeLists.txt ของ target แต่ละตัว ในกรณีของโปรแกรม square ไฟล์ CMakeLists.txt&lt;br /&gt;
ของมันมีเนื้อหาดังต่อไปนี้&lt;br /&gt;
&lt;br /&gt;
    INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIR})&lt;br /&gt;
&lt;br /&gt;
    ADD_EXECUTABLE(square square.cpp)&lt;br /&gt;
&lt;br /&gt;
    TARGET_LINK_LIBRARIES(square ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES})&lt;br /&gt;
&lt;br /&gt;
=== คำสั่ง INCLUDE_DIRECTORIES ===&lt;br /&gt;
&lt;br /&gt;
มีรูปแบบ&lt;br /&gt;
&lt;br /&gt;
    INCLUDE_DIRECTORIES(&amp;lt;ไดเรคทอรี 1&amp;gt; &amp;lt;ไดเรคทอรี 2&amp;gt; ...)&lt;br /&gt;
    &lt;br /&gt;
โดยที่เราสามารถใส่ไดเรคทอรีกี่ไดเรคทอรีก็ได้ในวงเล็บ&lt;br /&gt;
หลังจากสั่งคำสั่งนี้แล้ว คอมไพเลอร์จะคอมไพล์ target ทุก target&lt;br /&gt;
โดยใช้ไดเรคทอรีที่กำหนดในการค้นหาไฟล์ header&lt;br /&gt;
(_หมายเหตุ:_ จริงๆ แล้วไม่ใช่ target ทุก target เสียทีเดียว&lt;br /&gt;
แต่เป็นทุก target ในไฟล์ CMakeLists.txt เดียวกัน&lt;br /&gt;
หรือไฟล์ CMakeLists.txt อื่นๆ ที่ปรากฏอยู่ในไดเรคทอรีย่อยที่ถูกเพิ่มผ่าน &lt;br /&gt;
ADD_SUBDIRECTORY กล่าวคือ คำสั่ง INCLUDE_DIRECTORIES ที่ปรากฏใน&lt;br /&gt;
src/square/CMakeLists.txt จะไม่มีผลต่อ target ที่ประกาศใน&lt;br /&gt;
src/cube/CMakeLists.txt หรือ src/cube/star/CMakeLists.txt เลย)&lt;br /&gt;
&lt;br /&gt;
=== คำสั่ง TARGET_LINK_LIBRARIES ===&lt;br /&gt;
&lt;br /&gt;
มีรูปแบบ&lt;br /&gt;
&lt;br /&gt;
    TARGET_LINK_LIBRARIES(&amp;lt;ชื่อ target&amp;gt; &amp;lt;ไลบรารี 1&amp;gt; &amp;lt;ไลบรารี 2&amp;gt; ...)&lt;br /&gt;
&lt;br /&gt;
โดยที่เราสามารถใส่ไลบรารีลงไปกี่ไลบรารีก็ได้หลังชื่อ target&lt;br /&gt;
คำสั่ง TARGET_LINK_LIBRARIES นี้เนื่องจากมันต้องใช้ชื่อ target &lt;br /&gt;
มันจึงถูกเรียกอยู่หลังคำสั่ง ADD_EXECUTABLE หรือ ADD_LIBRARY &lt;br /&gt;
(ที่เรายังไม่ได้พูดถึง)  ซึ่งเป็นตัวสร้าง target เสมอ&lt;br /&gt;
เมื่อสั่ง TARGET_LINK_LIBRARIES แล้ว target &lt;br /&gt;
ที่กำหนดจะถูกลิงก์เข้ากับไลบรารีที่เรากำหนดให้&lt;br /&gt;
&lt;br /&gt;
== สรุป ==&lt;br /&gt;
&lt;br /&gt;
หากต้องการใช้ไลบรารี (package) ภายนอกให้&lt;br /&gt;
&lt;br /&gt;
1. สั่ง FIND_PACKAGE(&amp;lt;package&amp;gt;) ใน CMakeLists.txt ของโปรเจค&lt;br /&gt;
&lt;br /&gt;
2. สั่ง INCLUDE_DIRECTORIES(&amp;lt;PACKAGE&amp;gt;_INCLUDE_DIR) &lt;br /&gt;
ใน CMakeLists.txt ของ target ที่จะต้องใช้ package ก่อนการประกาศ target นั้นด้วย&lt;br /&gt;
ADD_EXECUTABLE หรือ ADD_LIBRARY&lt;br /&gt;
&lt;br /&gt;
3. สั่ง TARGET_LINK_LIBRARIES(&amp;lt;target&amp;gt; &amp;lt;PACKAGE&amp;gt;_LIBRARIES)&lt;br /&gt;
ใน CMakeLists.txt ของ target หลังประกาศ target แล้ว&lt;/div&gt;</summary>
		<author><name>Cardcaptor</name></author>
		
	</entry>
</feed>