summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorPeter Johnson <peter@tortall.net>2008-05-22 09:08:03 +0000
committerPeter Johnson <peter@tortall.net>2008-05-22 09:08:03 +0000
commitb7f2fbc64fcfe8e30650a32e3354613aceaceb0c (patch)
tree785bf9ebd79ce3369af295bfbeea0b75faffa5be /cmake
parent811d7ad566a3e7df758c47d4f11dcf4ea82a403d (diff)
downloadyasm-b7f2fbc64fcfe8e30650a32e3354613aceaceb0c.tar.gz
Add cmake build infrastructure.
Not default nor even distributed in the .tar.gz, the cmake build allows for loadable yasm plugins by building libyasm as a shared library. Example plugins are in the plugins/ directory, and may be loaded into a cmake-built yasm using the -N command line option (non-cmake builds will not have this option). Tested only on Linux so far, but should be relatively painless to port to Windows thanks to the use of cmake rather than libtool to create shared libraries. The only modification to the main source tree is some conditional-compiled additions to yasm.c. svn path=/trunk/yasm/; revision=2098
Diffstat (limited to 'cmake')
-rw-r--r--cmake/CMakeLists.txt1
-rw-r--r--cmake/modules/CMakeLists.txt2
-rw-r--r--cmake/modules/DummyCFile.c4
-rw-r--r--cmake/modules/YasmMacros.cmake89
4 files changed, 96 insertions, 0 deletions
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
new file mode 100644
index 00000000..5e4ef796
--- /dev/null
+++ b/cmake/CMakeLists.txt
@@ -0,0 +1 @@
+ADD_SUBDIRECTORY(modules)
diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt
new file mode 100644
index 00000000..e4351fc9
--- /dev/null
+++ b/cmake/modules/CMakeLists.txt
@@ -0,0 +1,2 @@
+FILE(GLOB cmakeFiles "${CMAKE_CURRENT_SOURCE_DIR}/*.cmake")
+
diff --git a/cmake/modules/DummyCFile.c b/cmake/modules/DummyCFile.c
new file mode 100644
index 00000000..f8b643af
--- /dev/null
+++ b/cmake/modules/DummyCFile.c
@@ -0,0 +1,4 @@
+int main()
+{
+ return 0;
+}
diff --git a/cmake/modules/YasmMacros.cmake b/cmake/modules/YasmMacros.cmake
new file mode 100644
index 00000000..ab1be00e
--- /dev/null
+++ b/cmake/modules/YasmMacros.cmake
@@ -0,0 +1,89 @@
+# Portions based on kdelibs KDE4Macros.cmake:
+#
+# Copyright (c) 2006, 2007, Alexander Neundorf, <neundorf@kde.org>
+# Copyright (c) 2006, 2007, Laurent Montel, <montel@kde.org>
+# Copyright (c) 2007 Matthias Kretz <kretz@kde.org>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+#
+# Changes for Yasm Copyright (c) 2007 Peter Johnson
+
+# add a unit test, which is executed when running make test
+# it will be built with RPATH pointing to the build dir
+# The targets are always created, but only built for the "all"
+# target if the option YASM_BUILD_TESTS is enabled. Otherwise the rules for
+# the target are created but not built by default. You can build them by
+# manually building the target.
+# The name of the target can be specified using TESTNAME <testname>, if it is
+# not given the macro will default to the <name>
+macro (YASM_ADD_UNIT_TEST _test_NAME)
+ set(_srcList ${ARGN})
+ set(_targetName ${_test_NAME})
+ if( ${ARGV1} STREQUAL "TESTNAME" )
+ set(_targetName ${ARGV2})
+ LIST(REMOVE_AT _srcList 0 1)
+ endif( ${ARGV1} STREQUAL "TESTNAME" )
+ yasm_add_test_executable( ${_test_NAME} ${_srcList} )
+ add_test( ${_targetName} ${EXECUTABLE_OUTPUT_PATH}/${_test_NAME} )
+endmacro (YASM_ADD_UNIT_TEST)
+
+# add an test executable
+# it will be built with RPATH pointing to the build dir
+# The targets are always created, but only built for the "all"
+# target if the option YASM_BUILD_TESTS is enabled. Otherwise the rules for
+# the target are created but not built by default. You can build them by
+# manually building the target.
+macro (YASM_ADD_TEST_EXECUTABLE _target_NAME)
+
+ set(_add_executable_param)
+
+ if (NOT YASM_BUILD_TESTS)
+ set(_add_executable_param EXCLUDE_FROM_ALL)
+ endif (NOT YASM_BUILD_TESTS)
+
+ set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
+
+ set(_SRCS ${ARGN})
+ add_executable(${_target_NAME} ${_add_executable_param} ${_SRCS})
+
+ set_target_properties(${_target_NAME} PROPERTIES
+ SKIP_BUILD_RPATH FALSE
+ BUILD_WITH_INSTALL_RPATH FALSE)
+
+endmacro (YASM_ADD_TEST_EXECUTABLE)
+
+macro (YASM_ADD_MODULE _module_NAME)
+ list(APPEND YASM_MODULES_SRC ${ARGN})
+ list(APPEND YASM_MODULES ${_module_NAME})
+endmacro (YASM_ADD_MODULE)
+
+macro (YASM_GENPERF _in_NAME _out_NAME)
+ get_target_property(_tmp_GENPERF_EXE genperf LOCATION)
+ add_custom_command(
+ OUTPUT ${_out_NAME}
+ COMMAND ${_tmp_GENPERF_EXE} ${_in_NAME} ${_out_NAME}
+ DEPENDS ${_tmp_GENPERF_EXE}
+ MAIN_DEPENDENCY ${_in_NAME}
+ )
+endmacro (YASM_GENPERF)
+
+macro (YASM_RE2C _in_NAME _out_NAME)
+ get_target_property(_tmp_RE2C_EXE re2c LOCATION)
+ add_custom_command(
+ OUTPUT ${_out_NAME}
+ COMMAND ${_tmp_RE2C_EXE} ${ARGN} -o ${_out_NAME} ${_in_NAME}
+ DEPENDS ${_tmp_RE2C_EXE}
+ MAIN_DEPENDENCY ${_in_NAME}
+ )
+endmacro (YASM_RE2C)
+
+macro (YASM_GENMACRO _in_NAME _out_NAME _var_NAME)
+ get_target_property(_tmp_GENMACRO_EXE genmacro LOCATION)
+ add_custom_command(
+ OUTPUT ${_out_NAME}
+ COMMAND ${_tmp_GENMACRO_EXE} ${_out_NAME} ${_var_NAME} ${_in_NAME}
+ DEPENDS ${_tmp_GENMACRO_EXE}
+ MAIN_DEPENDENCY ${_in_NAME}
+ )
+endmacro (YASM_GENMACRO)
+