From 636dc92558efd052cd0553203f67068171a3116c Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sun, 10 Aug 2014 21:38:48 -0700 Subject: Allow building of static executables with cmake. --- modules/CMakeLists.txt | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'modules') diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 48a3b5cf..e3f8eb11 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -56,9 +56,11 @@ IF(regen_init_plugin_c) FILE(APPEND ${INIT_PLUGIN_C} "extern yasm_${_type}_module yasm_${_keyword}_LTX_${_type};\n") ENDFOREACH(module) - FILE(APPEND ${INIT_PLUGIN_C} "\n#ifdef _MSC_VER\n") - FILE(APPEND ${INIT_PLUGIN_C} "__declspec(dllexport)\n") - FILE(APPEND ${INIT_PLUGIN_C} "#endif\n") + IF(BUILD_SHARED_LIBS) + FILE(APPEND ${INIT_PLUGIN_C} "\n#ifdef _MSC_VER\n") + FILE(APPEND ${INIT_PLUGIN_C} "__declspec(dllexport)\n") + FILE(APPEND ${INIT_PLUGIN_C} "#endif\n") + ENDIF(BUILD_SHARED_LIBS) FILE(APPEND ${INIT_PLUGIN_C} "void\n") FILE(APPEND ${INIT_PLUGIN_C} "yasm_init_plugin(void)\n") FILE(APPEND ${INIT_PLUGIN_C} "{\n") @@ -80,14 +82,22 @@ SET_SOURCE_FILES_PROPERTIES(init_plugin.c GENERATED) SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}) -ADD_LIBRARY(yasmstd MODULE - init_plugin.c - ${YASM_MODULES_SRC} - ) -TARGET_LINK_LIBRARIES(yasmstd libyasm) +IF(BUILD_SHARED_LIBS) + ADD_LIBRARY(yasmstd MODULE + init_plugin.c + ${YASM_MODULES_SRC} + ) + TARGET_LINK_LIBRARIES(yasmstd libyasm) -IF(WIN32) - INSTALL(TARGETS yasmstd LIBRARY DESTINATION bin) -ELSE(WIN32) - INSTALL(TARGETS yasmstd LIBRARY DESTINATION lib) -ENDIF(WIN32) + IF(WIN32) + INSTALL(TARGETS yasmstd LIBRARY DESTINATION bin) + ELSE(WIN32) + INSTALL(TARGETS yasmstd LIBRARY DESTINATION lib) + ENDIF(WIN32) +ELSE(BUILD_SHARED_LIBS) + ADD_LIBRARY(yasmstd + init_plugin.c + ${YASM_MODULES_SRC} + ) + TARGET_LINK_LIBRARIES(yasmstd libyasm) +ENDIF(BUILD_SHARED_LIBS) -- cgit v1.2.1