Browse Source

Export luaopen_https

And hide other symbols everywhere (well.. when using gcc or clang)
Bart van Strien 6 years ago
parent
commit
9829e3fea6
4 changed files with 12 additions and 2 deletions
  1. 1 1
      CMakeLists.txt
  2. 9 0
      src/CMakeLists.txt
  3. 1 0
      src/common/config.h.in
  4. 1 1
      src/lua/main.cpp

+ 1 - 1
CMakeLists.txt

@@ -1,5 +1,5 @@
 cmake_minimum_required (VERSION 2.6)
 
-project (Https)
+project (Https CXX)
 
 add_subdirectory (src)

+ 9 - 0
src/CMakeLists.txt

@@ -9,6 +9,15 @@ include_directories (
 	${CMAKE_CURRENT_BINARY_DIR}
 )
 
+### Compiler-specific flags
+if (${CMAKE_CXX_COMPILER_ID} MATCHES "MSVC")
+	set (DLLEXPORT "__declspec(dllexport)")
+elseif (${CMAKE_CXX_COMPILER_ID} MATCHES "GNU" OR ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
+	set (DLLEXPORT "__attribute__((visibility(\"default\")))")
+	add_compile_options ("-fvisibility=hidden")
+	add_link_options ("-fvisibility=hidden")
+endif ()
+
 ### "Libraries"
 add_library (https MODULE
 	lua/main.cpp

+ 1 - 0
src/common/config.h.in

@@ -3,3 +3,4 @@
 #cmakedefine USE_SCHANNEL_BACKEND
 #cmakedefine USE_NSURL_BACKEND
 #cmakedefine USE_WINSOCK
+#define DLLEXPORT @DLLEXPORT@

+ 1 - 1
src/lua/main.cpp

@@ -168,7 +168,7 @@ static int w_request(lua_State *L)
 	return advanced ? 3 : 2;
 }
 
-extern "C" int luaopen_https(lua_State *L)
+extern "C" int DLLEXPORT luaopen_https(lua_State *L)
 {
 	lua_newtable(L);